From 6870be20290e6f70afb6f22e83f6e43b31229a38 Mon Sep 17 00:00:00 2001 From: Mike Brocchi Date: Mon, 9 Apr 2018 22:33:26 -0400 Subject: [PATCH] fix(@angular/cli): Show dry run warning fixes #10194 --- .../@angular/cli/models/schematic-command.ts | 47 ++++++++++--------- .../tests/generate/service/service-dry-run.ts | 5 ++ 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/packages/@angular/cli/models/schematic-command.ts b/packages/@angular/cli/models/schematic-command.ts index 617fa68a37..469a05bc45 100644 --- a/packages/@angular/cli/models/schematic-command.ts +++ b/packages/@angular/cli/models/schematic-command.ts @@ -152,30 +152,33 @@ export abstract class SchematicCommand extends Command { logger: this.logger as any, allowPrivate: this.allowPrivateSchematics, }) - .subscribe({ - error: (err: Error) => { - // In case the workflow was not successful, show an appropriate error message. - if (err instanceof UnsuccessfulWorkflowExecution) { - // "See above" because we already printed the error. - this.logger.fatal('The Schematic workflow failed. See above.'); - } else if (debug) { - this.logger.fatal(`An error occured:\n${err.message}\n${err.stack}`); - } else { - this.logger.fatal(err.message); - } + .subscribe({ + error: (err: Error) => { + // In case the workflow was not successful, show an appropriate error message. + if (err instanceof UnsuccessfulWorkflowExecution) { + // "See above" because we already printed the error. + this.logger.fatal('The Schematic workflow failed. See above.'); + } else if (debug) { + this.logger.fatal(`An error occured:\n${err.message}\n${err.stack}`); + } else { + this.logger.fatal(err.message); + } - reject(1); - }, - complete: () => { - // Output the logging queue, no error happened. - loggingQueue.forEach(log => this.logger.info(log)); + reject(1); + }, + complete: () => { + // Output the logging queue, no error happened. + loggingQueue.forEach(log => this.logger.info(log)); - if (nothingDone) { - this.logger.info('Nothing to be done.'); - } - resolve(); - }, - }); + if (nothingDone) { + this.logger.info('Nothing to be done.'); + } + if (dryRun) { + this.logger.warn(`\nNOTE: Run with "dry run" no changes were made.`); + } + resolve(); + }, + }); }); } diff --git a/tests/e2e/tests/generate/service/service-dry-run.ts b/tests/e2e/tests/generate/service/service-dry-run.ts index a7f2e20959..43b17ffa96 100644 --- a/tests/e2e/tests/generate/service/service-dry-run.ts +++ b/tests/e2e/tests/generate/service/service-dry-run.ts @@ -4,5 +4,10 @@ import {expectGitToBeClean} from '../../../utils/git'; export default function() { return ng('generate', 'service', 'test-service', '--module', 'app.module.ts', '--dry-run') + .then(({stdout}) => { + if (!/NOTE: Run with "dry run" no changes were made/.test(stdout)) { + throw 'Dry run warning not shown.'; + } + }) .then(() => expectGitToBeClean()); }