Skip to content

Commit a3bc7dc

Browse files
committed
make composeWith optionally async.
1 parent a8edf4f commit a3bc7dc

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/actions/lifecycle.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -454,39 +454,36 @@ export abstract class TasksMixin {
454454
* @example <caption>Passing a Generator class</caption>
455455
* await this.composeWith({ Generator: MyGenerator, path: '../generator-bootstrap/app/main.js' }, { sass: true });
456456
*/
457-
async composeWith<G extends BaseGenerator = BaseGenerator>(
457+
composeWith<G extends BaseGenerator = BaseGenerator>(
458458
generator: string | { Generator: any; path: string },
459459
immediately?: boolean,
460460
): Promise<G>;
461-
async composeWith<G extends BaseGenerator = BaseGenerator>(generator: string[], immediately?: boolean): Promise<G[]>;
462-
async composeWith<G extends BaseGenerator = BaseGenerator>(
461+
composeWith<G extends BaseGenerator = BaseGenerator>(generator: string[], immediately?: boolean): Promise<G[]>;
462+
composeWith<G extends BaseGenerator = BaseGenerator>(
463463
generator: string | { Generator: any; path: string },
464464
options: Partial<GetGeneratorOptions<G>>,
465465
immediately?: boolean,
466466
): Promise<G>;
467-
async composeWith<G extends BaseGenerator = BaseGenerator>(
467+
composeWith<G extends BaseGenerator = BaseGenerator>(
468468
generator: string[],
469469
options: Partial<GetGeneratorOptions<G>>,
470470
immediately?: boolean,
471471
): Promise<G[]>;
472-
async composeWith<G extends BaseGenerator = BaseGenerator>(
472+
composeWith<G extends BaseGenerator = BaseGenerator>(
473473
generator: string | { Generator: any; path: string },
474474
args: string[],
475475
options?: Partial<GetGeneratorOptions<G>>,
476476
immediately?: boolean,
477477
): Promise<G>;
478-
async composeWith<G extends BaseGenerator = BaseGenerator>(
478+
composeWith<G extends BaseGenerator = BaseGenerator>(
479479
generator: string[],
480480
args: string[],
481481
options?: Partial<GetGeneratorOptions<G>>,
482482
immediately?: boolean,
483483
): Promise<G[]>;
484-
async composeWith<G extends BaseGenerator = BaseGenerator>(
485-
generator: string,
486-
options?: ComposeOptions<G>,
487-
): Promise<G>;
484+
composeWith<G extends BaseGenerator = BaseGenerator>(generator: string, options?: ComposeOptions<G>): Promise<G>;
488485

489-
async composeWith<G extends BaseGenerator = BaseGenerator>(
486+
composeWith<G extends BaseGenerator = BaseGenerator>(
490487
this: BaseGeneratorImpl,
491488
generator: string | string[] | { Generator: any; path: string },
492489
args?:
@@ -496,14 +493,17 @@ export abstract class TasksMixin {
496493
| ComposeOptions<G>,
497494
options?: Partial<GetGeneratorOptions<G>> | boolean,
498495
immediately = false,
499-
): Promise<G | G[]> {
496+
): Promise<G | G[]> | G {
500497
if (Array.isArray(generator)) {
501-
const generators: Generator[] = [];
502-
for (const each of generator) {
503-
generators.push(await this.composeWith(each, args as any, options as any));
504-
}
498+
const composeWithArray = async () => {
499+
const generators: G[] = [];
500+
for (const each of generator) {
501+
generators.push(await this.composeWith<G>(each, args as any, options as any));
502+
}
503+
return generators;
504+
};
505505

506-
return generators as any;
506+
return composeWithArray();
507507
}
508508

509509
if (

0 commit comments

Comments
 (0)