diff --git a/packages/node-cli-testing/cli-project/src/lib/utils.ts b/packages/node-cli-testing/cli-project/src/lib/utils.ts index 8753fcb..5ac0e19 100644 --- a/packages/node-cli-testing/cli-project/src/lib/utils.ts +++ b/packages/node-cli-testing/cli-project/src/lib/utils.ts @@ -1,7 +1,8 @@ import * as fs from 'fs'; -import { ProcessParams } from './types'; +import { ProcessParams, ProjectConfig } from './types'; import * as path from 'path'; import {CliProjectFactory} from "./factory"; +import {CliProject} from "./cli"; export function getFolderContent(folders: string[]): string[] { return folders.flatMap((d) => { @@ -46,9 +47,12 @@ export function processParamsToParamsArray(params: ProcessParams): string[] { }) as string[]; } -export function withProject(cfg: any, fn: (prj: unknown) => Promise): () => Promise { - return async () => { - let prj = await CliProjectFactory.create(cfg); +export function withProject( + cfg: any, + fn: (prj: unknown) => Promise, + factory: Record<'create', (cfg: ProjectConfig) => Promise>> = CliProjectFactory +): () => Promise { return async () => { + let prj = await factory.create(cfg); await prj.setup(); await fn(prj).finally(() => prj.teardown()); }