Skip to content

Commit a47676b

Browse files
committed
fix(@angular/cli): show a nicer error if packages does not support schematics
Does not show a better error if there are schematics but ng-add isnt found. That will simply show "schematics ng-add not found" or something alike, which is fine here. fixes #10467
1 parent 0fc72bb commit a47676b

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { tags } from '@angular-devkit/core';
2+
import { NodePackageDoesNotSupportSchematics } from '@angular-devkit/schematics/tools';
13
import chalk from 'chalk';
24
import { CommandScope, Option } from '../models/command';
35
import { parseOptions } from '../models/command-runner';
@@ -81,6 +83,17 @@ export default class AddCommand extends SchematicCommand {
8183
force: false,
8284
};
8385

84-
return await this.runSchematic(runOptions);
86+
try {
87+
return await this.runSchematic(runOptions);
88+
} catch (e) {
89+
if (e instanceof NodePackageDoesNotSupportSchematics) {
90+
throw new SilentError(tags.oneLine`
91+
The package that you are trying to add does not support schematics. You can try using
92+
a different version of the package or contact the package author to add ng-add support.
93+
`);
94+
}
95+
96+
throw e;
97+
}
8598
}
8699
}

0 commit comments

Comments
 (0)