Fix plugin remove command for invalid plugins #1590
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When invalid plugin data is written in project's package.json,
tns plugin remove <name>
command fails.In such cases
npm uninstall --save <name>
just removes the entry from package.json, so we should do the same.By invalid data I mean invalid version (not existing version or path to non-existing file).
Plugin remove command's canExecute method is trying to install all plugins in order to get information about their native code, so it will be removed from
platforms
dir.The installation fails when some plugin's data is invalid.
Catch the error and check package.json's dependencies instead.
Also make sure plugin variables data is removed from package.json when plugin is removed.
Currently it's been removed only when platform is added and plugin has native code.
Fixes #1541