diff --git a/packages/@angular/cli/blueprints/service/index.ts b/packages/@angular/cli/blueprints/service/index.ts index e5254aa4f945..23f5cbd34049 100644 --- a/packages/@angular/cli/blueprints/service/index.ts +++ b/packages/@angular/cli/blueprints/service/index.ts @@ -103,6 +103,13 @@ export default Blueprint.extend({ `; this._writeStatusToUI(chalk.yellow, 'WARNING', warningMessage); } else { + if (options.dryRun) { + this._writeStatusToUI(chalk.yellow, + 'update', + path.relative(this.project.root, this.pathToModule)); + return; + } + const className = stringUtils.classify(`${options.entity.name}Service`); const fileName = stringUtils.dasherize(`${options.entity.name}.service`); const fullGeneratePath = path.join(this.project.root, this.generatePath); diff --git a/tests/e2e/tests/generate/service/service-dry-run.ts b/tests/e2e/tests/generate/service/service-dry-run.ts new file mode 100644 index 000000000000..b429c3e3cb45 --- /dev/null +++ b/tests/e2e/tests/generate/service/service-dry-run.ts @@ -0,0 +1,9 @@ +import {join} from 'path'; +import {ng} from '../../../utils/process'; +import {expectGitToBeClean} from '../../../utils/git'; + + +export default function() { + return ng('generate', 'service', 'test-service', '--module', 'app.module.ts', '--dry-run') + .then(() => expectGitToBeClean()); +}