From dff0a91f8846a404f3fc0f5346209cbd89f73022 Mon Sep 17 00:00:00 2001 From: Michael Hladky Date: Fri, 3 Feb 2023 21:57:14 +0100 Subject: [PATCH] fix: add typing --- .../node-cli-testing/cli-project/src/lib/utils.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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()); }