Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4c551e9

Browse files
committed
refactor(@angular/cli): verify ng-add schematic exists in ng add
When running `ng add`, the command will now not only check if a package has schematics but also verify that a schematic named `ng-add` is available in the collection. This prevents cases where a package has a schematics entry in its `package.json` but does not contain the actual `ng-add` schematic, causing the command to fail.
1 parent 2c498d2 commit 4c551e9

File tree

1 file changed

+10
-0
lines changed
  • packages/angular/cli/src/commands/add

1 file changed

+10
-0
lines changed

‎packages/angular/cli/src/commands/add/cli.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@ export default class AddCommandModule
218218
const result = await tasks.run(taskContext);
219219
assert(result.collectionName, 'Collection name should always be available');
220220

221+
// Check if the installed package has actual add actions and not just schematic support
222+
if (result.hasSchematics && !options.dryRun) {
223+
const workflow = this.getOrCreateWorkflowForBuilder(result.collectionName);
224+
const collection = workflow.engine.createCollection(result.collectionName);
225+
226+
if (!collection.listSchematicNames().includes(this.schematicName)) {
227+
result.hasSchematics = false;
228+
}
229+
}
230+
221231
if (!result.hasSchematics) {
222232
let message = options.dryRun
223233
? 'The package does not provide any `ng add` actions, so no further actions would be taken.'

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /