Skip to content

Commit 82649b6

Browse files
committed
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 b8b36ba commit 82649b6

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
@@ -57,6 +57,11 @@
5757
"type": "boolean",
5858
"default": "true",
5959
"description": "Disables interactive inputs (i.e., prompts)."
60+
},
61+
"defaults": {
62+
"type": "boolean",
63+
"default": "false",
64+
"description": "Disables interactive inputs (i.e., prompts) for options with a default."
6065
}
6166
}
6267
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export interface BaseSchematicOptions extends BaseCommandOptions {
5353
dryRun?: boolean;
5454
force?: boolean;
5555
interactive?: boolean;
56+
defaults?: boolean;
5657
}
5758

5859
export interface RunSchematicOptions {
@@ -234,7 +235,11 @@ export abstract class SchematicCommand<
234235

235236
this._engineHost.registerOptionsTransform(validateOptionsWithSchema(workflow.registry));
236237

237-
workflow.registry.addPostTransform(schema.transforms.addUndefinedDefaults);
238+
if (options.defaults) {
239+
workflow.registry.addPreTransform(schema.transforms.addUndefinedDefaults);
240+
} else {
241+
workflow.registry.addPostTransform(schema.transforms.addUndefinedDefaults);
242+
}
238243

239244
workflow.registry.addSmartDefaultProvider('projectName', () => {
240245
if (this._workspace) {

0 commit comments

Comments
 (0)