Skip to content

fix(@angular/cli): show a nicer error if packages does not support schematics #10488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion packages/@angular/cli/commands/add.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { tags } from '@angular-devkit/core';
import { NodePackageDoesNotSupportSchematics } from '@angular-devkit/schematics/tools';
import chalk from 'chalk';
import { CommandScope, Option } from '../models/command';
import { parseOptions } from '../models/command-runner';
Expand Down Expand Up @@ -81,6 +83,17 @@ export default class AddCommand extends SchematicCommand {
force: false,
};

return await this.runSchematic(runOptions);
try {
return await this.runSchematic(runOptions);
} catch (e) {
if (e instanceof NodePackageDoesNotSupportSchematics) {
throw new SilentError(tags.oneLine`
The package that you are trying to add does not support schematics. You can try using
a different version of the package or contact the package author to add ng-add support.
`);
}

throw e;
}
}
}