Skip to content

Commit

Permalink
fix(@angular/cli): correctly handle --collection option in ng new
Browse files Browse the repository at this point in the history
Previously, this option was ignored due to an incorrect deconstruction.

Closes #23414
  • Loading branch information
alan-agius4 authored and clydin committed Jun 27, 2022
1 parent b40aeed commit 5a012b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/angular/cli/src/commands/new/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class NewCommandModule
});

const {
options: { collectionNameFromArgs },
options: { collection: collectionNameFromArgs },
} = this.context.args;

const collectionName =
Expand Down
19 changes: 19 additions & 0 deletions tests/legacy-cli/e2e/tests/commands/ng-new-collection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { execAndWaitForOutputToMatch } from '../../utils/process';

export default async function () {
const currentDirectory = process.cwd();

try {
process.chdir('..');

// The below is a way to validate that the `--collection` option is being considered.
await execAndWaitForOutputToMatch(
'ng',
['new', '--collection', 'invalid-schematic'],
/Collection "invalid-schematic" cannot be resolved/,
);
} finally {
// Change directory back
process.chdir(currentDirectory);
}
}

0 comments on commit 5a012b5

Please sign in to comment.