diff --git a/packages/angular_devkit/schematics_cli/bin/schematics.ts b/packages/angular_devkit/schematics_cli/bin/schematics.ts index 806afff2d2b4..31619a0f6ddc 100644 --- a/packages/angular_devkit/schematics_cli/bin/schematics.ts +++ b/packages/angular_devkit/schematics_cli/bin/schematics.ts @@ -107,6 +107,7 @@ function _createPromptProvider(): schema.PromptProvider { }; } +// eslint-disable-next-line max-lines-per-function export async function main({ args, stdout = process.stdout, @@ -141,8 +142,10 @@ export async function main({ const isLocalCollection = collectionName.startsWith('.') || collectionName.startsWith('/'); /** Gather the arguments for later use. */ - const debug: boolean = argv.debug === null ? isLocalCollection : argv.debug; - const dryRun: boolean = argv['dry-run'] === null ? debug : argv['dry-run']; + const debugPresent = argv['debug'] !== null; + const debug = debugPresent ? !!argv['debug'] : isLocalCollection; + const dryRunPresent = argv['dry-run'] !== null; + const dryRun = dryRunPresent ? !!argv['dry-run'] : debug; const force = argv['force']; const allowPrivate = argv['allow-private']; @@ -165,6 +168,12 @@ export async function main({ return 1; } + if (debug) { + logger.info( + `Debug mode enabled${isLocalCollection ? ' by default for local collections' : ''}.`, + ); + } + // Indicate to the user when nothing has been done. This is automatically set to off when there's // a new DryRunEvent. let nothingDone = true; @@ -285,6 +294,12 @@ export async function main({ if (nothingDone) { logger.info('Nothing to be done.'); + } else if (dryRun) { + logger.info( + `Dry run enabled${ + dryRunPresent ? '' : ' by default in debug mode' + }. No files written to disk.`, + ); } return 0; diff --git a/packages/angular_devkit/schematics_cli/bin/schematics_spec.ts b/packages/angular_devkit/schematics_cli/bin/schematics_spec.ts index 3c71096915c6..2055d474333e 100644 --- a/packages/angular_devkit/schematics_cli/bin/schematics_spec.ts +++ b/packages/angular_devkit/schematics_cli/bin/schematics_spec.ts @@ -50,16 +50,19 @@ describe('schematics-cli binary', () => { expect(stdout.lines).toMatch(/CREATE foo\/.gitignore/); expect(stdout.lines).toMatch(/CREATE foo\/src\/foo\/index.ts/); expect(stdout.lines).toMatch(/CREATE foo\/src\/foo\/index_spec.ts/); + expect(stdout.lines).toMatch(/Dry run enabled./); expect(res).toEqual(0); }); it('dry-run is default when debug mode', async () => { const args = ['blank', 'foo', '--debug']; const res = await main({ args, stdout, stderr }); + expect(stdout.lines).toMatch(/Debug mode enabled./); expect(stdout.lines).toMatch(/CREATE foo\/README.md/); expect(stdout.lines).toMatch(/CREATE foo\/.gitignore/); expect(stdout.lines).toMatch(/CREATE foo\/src\/foo\/index.ts/); expect(stdout.lines).toMatch(/CREATE foo\/src\/foo\/index_spec.ts/); + expect(stdout.lines).toMatch(/Dry run enabled by default in debug mode./); expect(res).toEqual(0); });