Skip to content

Commit 75d682b

Browse files
hanslalexeagle
authored andcommitted
refactor(@angular/cli): use smart default instead of overwriting args
1 parent 1b5c008 commit 75d682b

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

packages/angular/cli/commands/new-impl.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ export class NewCommand extends SchematicCommand {
4444
collectionName = this.parseCollectionName(options);
4545
}
4646

47+
// Register the version of the CLI in the registry.
4748
const packageJson = require('../package.json');
48-
options.version = packageJson.version;
49+
const version = packageJson.version;
4950

5051
// Ensure skipGit has a boolean value.
5152
options.skipGit = options.skipGit === undefined ? false : options.skipGit;
53+
this._workflow.registry.addSmartDefaultProvider('ng-cli-version', () => version);
5254

5355
return this.runSchematic({
5456
collectionName: collectionName,

packages/schematics/angular/ng-new/schema.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@
9090
"version": {
9191
"type": "string",
9292
"description": "The version of the Angular CLI to use.",
93-
"visible": false
93+
"visible": false,
94+
"$default": {
95+
"$source": "ng-cli-version"
96+
}
9497
},
9598
"routing": {
9699
"type": "boolean",
@@ -117,6 +120,5 @@
117120
}
118121
},
119122
"required": [
120-
"version"
121123
]
122124
}

packages/schematics/angular/workspace/schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@
6969
"version": {
7070
"type": "string",
7171
"description": "The version of the Angular CLI to use.",
72-
"visible": false
72+
"visible": false,
73+
"$default": {
74+
"$source": "ng-cli-version"
75+
}
7376
}
7477
},
7578
"required": [

0 commit comments

Comments
 (0)