From f46a883330bd7c6bd48bdf7c607a055aaea413f7 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 25 Jun 2018 15:30:40 +0200 Subject: [PATCH] refactor(@angular/cli): remove extra `await` An async function always wraps the return value in a Promise. Using return await just adds extra time before the overreaching promise is resolved without changing the semantics. --- packages/angular/cli/commands/e2e.ts | 2 +- packages/angular/cli/models/architect-command.ts | 4 +++- packages/angular/cli/models/command-runner.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/angular/cli/commands/e2e.ts b/packages/angular/cli/commands/e2e.ts index fd373a95ed..934241232c 100644 --- a/packages/angular/cli/commands/e2e.ts +++ b/packages/angular/cli/commands/e2e.ts @@ -22,7 +22,7 @@ export default class E2eCommand extends ArchitectCommand { this.configurationOption, ]; - public run(options: ArchitectCommandOptions) { + public async run(options: ArchitectCommandOptions) { return this.runArchitectTarget(options); } } diff --git a/packages/angular/cli/models/architect-command.ts b/packages/angular/cli/models/architect-command.ts index 117b8d47ae..1a074e3a20 100644 --- a/packages/angular/cli/models/architect-command.ts +++ b/packages/angular/cli/models/architect-command.ts @@ -177,7 +177,9 @@ export abstract class ArchitectCommand extends Command return await from(this.getProjectNamesByTarget(this.target)).pipe( concatMap(project => runSingleTarget({ ...targetSpec, project })), toArray(), - ).toPromise().then(results => results.every(res => res === 0) ? 0 : 1); + map(results => results.every(res => res === 0) ? 0 : 1), + ) + .toPromise(); } else { return await runSingleTarget(targetSpec).toPromise(); } diff --git a/packages/angular/cli/models/command-runner.ts b/packages/angular/cli/models/command-runner.ts index 695b00519e..03b4bdcdeb 100644 --- a/packages/angular/cli/models/command-runner.ts +++ b/packages/angular/cli/models/command-runner.ts @@ -169,7 +169,7 @@ export async function runCommand(commandMap: CommandMap, return 1; } - return await command.run(options); + return command.run(options); } }