Skip to content

Commit fc72c62

Browse files
alan-agius4clydin
authored andcommitted
fix(@angular/cli): correctly handle --collection option in ng new
Previously, this option was ignored due to an incorrect deconstruction. Closes #23414 (cherry picked from commit 5a012b5)
1 parent 282baff commit fc72c62

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/angular/cli/src/commands/new/cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class NewCommandModule
4545
});
4646

4747
const {
48-
options: { collectionNameFromArgs },
48+
options: { collection: collectionNameFromArgs },
4949
} = this.context.args;
5050

5151
const collectionName =
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { execAndWaitForOutputToMatch } from '../../utils/process';
2+
3+
export default async function () {
4+
const currentDirectory = process.cwd();
5+
6+
try {
7+
process.chdir('..');
8+
9+
// The below is a way to validate that the `--collection` option is being considered.
10+
await execAndWaitForOutputToMatch(
11+
'ng',
12+
['new', '--collection', 'invalid-schematic'],
13+
/Collection "invalid-schematic" cannot be resolved/,
14+
);
15+
} finally {
16+
// Change directory back
17+
process.chdir(currentDirectory);
18+
}
19+
}

0 commit comments

Comments
 (0)