You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix getting information for installed npm package (#2813)
Some npm versions (like 3.9.6) do not report result when package is already installed and `--dry-run` is passed.
This breaks the `JSON.parse()` of the result as it is an empty string.
In this case just parse the original output of `npm install` and search for a result like:
```
<project dir>
`-- [email protected]
```
In case this operation also fails to find which is the installed package, try to find the name from the user specified value.
For example:
```
$ tns plugin add [email protected]
```
The name is `nativescript-barcodescanner` and the version is `1.0.0`.
In case a scoped package is passed, the parsing should also work correctly.
In case a package, that is not NativeScript plugin, is installed via `tns plugin add` command, we have logic to revert the installation.
However the promise that should uninstall the app had never been awaited, so the package was still declared and installed.
When `--json` is passed to `npm install` command, it generates `/etc` dir in the project where npm command is executed.
We have logic to delete it after finishing our command, but it's been executed too early. Fix the code, so command to remove `/etc` will be executed no matter if any of the other operations fails.
// Whenever calling npm install without any arguments (hence installing all dependencies) no output is emitted on stdout
56
56
// Luckily, whenever you call npm install to install all dependencies chances are you won't need the name/version of the package you're installing because there is none.
@@ -63,8 +63,8 @@ export class NodePackageManager implements INodePackageManager {
63
63
// We cannot use the actual install with --json to get the information because of post-install scripts which may print on stdout
64
64
// dry-run install is quite fast when the dependencies are already installed even for many dependencies (e.g. angular) so we can live with this approach
65
65
// We need the --prefix here because without it no output is emitted on stdout because all the dependencies are already installed.
this.$errors.failWithoutHelp(`${plugin} is not a valid NativeScript plugin. Verify that the plugin package.json file contains a nativescript key and try again.`);
0 commit comments