Skip to content

Commit

Permalink
fix: add typing
Browse files Browse the repository at this point in the history
  • Loading branch information
BioPhoton committed Feb 3, 2023
1 parent c5bade6 commit dff0a91
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/node-cli-testing/cli-project/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down Expand Up @@ -46,9 +47,12 @@ export function processParamsToParamsArray(params: ProcessParams): string[] {
}) as string[];
}

export function withProject<T extends { }>(cfg: any, fn: (prj: unknown) => Promise<void>): () => Promise<void> {
return async () => {
let prj = await CliProjectFactory.create<T>(cfg);
export function withProject<T extends {}>(
cfg: any,
fn: (prj: unknown) => Promise<void>,
factory: Record<'create', (cfg: ProjectConfig<T>) => Promise<CliProject<T>>> = CliProjectFactory
): () => Promise<void> { return async () => {
let prj = await factory.create(cfg);
await prj.setup();
await fn(prj).finally(() => prj.teardown());
}
Expand Down

0 comments on commit dff0a91

Please sign in to comment.