Skip to content

Commit 5d8af57

Browse files
clydinhansl
authored andcommitted
feat(@angular/cli): add --defaults option to ng new
Any option with a default value will not be prompted (if a prompt is defined) and the default will be used instead. Closes angular#12084
1 parent d582d80 commit 5d8af57

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/angular/cli/commands/definitions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@
5454
"type": "boolean",
5555
"default": "true",
5656
"description": "Disables interactive inputs (i.e., prompts)."
57+
},
58+
"defaults": {
59+
"type": "boolean",
60+
"default": "false",
61+
"description": "Disables interactive inputs (i.e., prompts) for options with a default."
5762
}
5863
}
5964
}

packages/angular/cli/models/schematic-command.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface BaseSchematicSchema {
5656
dryRun?: boolean;
5757
force?: boolean;
5858
interactive?: boolean;
59+
defaults?: boolean;
5960
}
6061

6162
export interface RunSchematicOptions extends BaseSchematicSchema {
@@ -262,7 +263,11 @@ export abstract class SchematicCommand<
262263

263264
this._engineHost.registerOptionsTransform(validateOptionsWithSchema(workflow.registry));
264265

265-
workflow.registry.addPostTransform(schema.transforms.addUndefinedDefaults);
266+
if (options.defaults) {
267+
workflow.registry.addPreTransform(schema.transforms.addUndefinedDefaults);
268+
} else {
269+
workflow.registry.addPostTransform(schema.transforms.addUndefinedDefaults);
270+
}
266271

267272
workflow.registry.addSmartDefaultProvider('projectName', () => {
268273
if (this._workspace) {

0 commit comments

Comments
 (0)