Skip to content

Commit f9d3060

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 f7f1d13 commit f9d3060

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

packages/angular/cli/commands/definitions.json

+5
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

+6
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 {
@@ -259,6 +260,11 @@ export abstract class SchematicCommand<
259260
});
260261

261262
if (options.interactive !== false && process.stdout.isTTY) {
263+
if (options.defaults) {
264+
(workflow.registry as schema.CoreSchemaRegistry)
265+
.addPreTransform(schema.transforms.addUndefinedDefaults);
266+
}
267+
262268
workflow.registry.usePromptProvider((definitions: Array<schema.PromptDefinition>) => {
263269
const questions: inquirer.Questions = definitions.map(definition => {
264270
const question: inquirer.Question = {

0 commit comments

Comments
 (0)