fix(@angular/cli): Show dry run warning

fixes #10194
This commit is contained in:
Mike Brocchi 2018-04-09 22:33:26 -04:00 committed by Filipe Silva
parent b62e3f6721
commit 6870be2029
2 changed files with 30 additions and 22 deletions

View File

@ -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();
},
});
});
}

View File

@ -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());
}