Skip to content

Commit f6f774a

Browse files
Broccohansl
authored andcommitted
fix(@angular/cli): Fix update command help options
fixes #10150
1 parent 645e0c5 commit f6f774a

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

packages/@angular/cli/commands/update.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,34 @@ export default class UpdateCommand extends SchematicCommand {
1313
public static aliases: string[] = [];
1414
public readonly scope = CommandScope.inProject;
1515
public readonly arguments: string[] = [ 'packages' ];
16-
public readonly options: Option[] = [
16+
public options: Option[] = [
1717
...this.coreOptions,
1818
];
1919
public readonly allowMissingWorkspace = true;
2020

21+
private collectionName = '@schematics/update';
22+
private schematicName = 'update';
23+
24+
private initialized = false;
25+
public async initialize(options: any) {
26+
if (this.initialized) {
27+
return;
28+
}
29+
super.initialize(options);
30+
this.initialized = true;
31+
32+
const availableOptions: Option[] = await this.getOptions({
33+
schematicName: this.schematicName,
34+
collectionName: this.collectionName,
35+
});
36+
this.options = this.options.concat( availableOptions || []);
37+
}
38+
2139
public async run(options: UpdateOptions) {
22-
const collectionName = '@schematics/update';
23-
const schematicName = 'update';
2440

2541
const schematicRunOptions = {
26-
collectionName,
27-
schematicName,
42+
collectionName: this.collectionName,
43+
schematicName: this.schematicName,
2844
schematicOptions: options,
2945
dryRun: options.dryRun,
3046
force: options.force,

tests/e2e/tests/misc/update-help.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ng } from '../../utils/process';
2+
3+
export default function () {
4+
return Promise.resolve()
5+
.then(() => ng('update', '--help'))
6+
.then(({ stdout }) => {
7+
if (!/next/.test(stdout)) {
8+
throw 'Update help should contain "next" option';
9+
}
10+
});
11+
}

0 commit comments

Comments
 (0)