Skip to content

Commit

Permalink
feat(@angular/cli): add --defaults option to ng new
Browse files Browse the repository at this point in the history
Any option with a default value will not be prompted (if a prompt is defined) and the default will be used instead.

Closes #12084
  • Loading branch information
clydin authored and hansl committed Sep 27, 2018
1 parent d582d80 commit 5d8af57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/angular/cli/commands/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
"type": "boolean",
"default": "true",
"description": "Disables interactive inputs (i.e., prompts)."
},
"defaults": {
"type": "boolean",
"default": "false",
"description": "Disables interactive inputs (i.e., prompts) for options with a default."
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion packages/angular/cli/models/schematic-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface BaseSchematicSchema {
dryRun?: boolean;
force?: boolean;
interactive?: boolean;
defaults?: boolean;
}

export interface RunSchematicOptions extends BaseSchematicSchema {
Expand Down Expand Up @@ -262,7 +263,11 @@ export abstract class SchematicCommand<

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

workflow.registry.addPostTransform(schema.transforms.addUndefinedDefaults);
if (options.defaults) {
workflow.registry.addPreTransform(schema.transforms.addUndefinedDefaults);
} else {
workflow.registry.addPostTransform(schema.transforms.addUndefinedDefaults);
}

workflow.registry.addSmartDefaultProvider('projectName', () => {
if (this._workspace) {
Expand Down

0 comments on commit 5d8af57

Please sign in to comment.