Simplify installation location retrieval (#18)

This replaces the whole existing logic to determine the path of an installed package with a new one.

Instead of a lot of guessing we now read the output of npm. Unfortunately we have to parse the human readable output since the information we need (which package was just installed) is not reliably extractable from the output generated when passing --json or --parseable.

Apart from a tremendous simplification of the existing code, with this change we now transparently support all spec formats that npm supports too.

The removal of getPath is a possibly breaking change. The function was neither documented nor used in any apache/cordova-* repositories though.

This supports all npm versions from 6 down to 3 (which are all that are bundled with supported node versions).
3 files changed
tree: b27f7b2bd533f8870781bdc6b1039c63fd6c2aa2
  1. spec/
  2. .eslintrc.yml
  3. .gitignore
  4. .ratignore
  5. .travis.yml
  6. appveyor.yml
  7. index.js
  8. package.json
  9. README.md
  10. RELEASENOTES.md
README.md

Build status Build Status NPM

cordova-fetch

This module is used for fetching modules from npm and gitURLs. It fetches the modules via npm install. It can also npm uninstall modules from a project.

Usage:

Fetching:

var fetch = require('cordova-fetch');

fetch(spec, dest, opts);

spec can be a string containg a npm packageID or a git URL. dest is string of the directory location you wish to npm install these modules. opts is an Object of options cordova fetch handles. Currently, fetch only support the save option. eg. {'save':true}

Removing:

var npmUninstall = require('cordova-fetch').uninstall;

npmUninstall(spec, dest, opts);

spec can be a string containg a npm packageID. dest is string of the directory location you wish to npm uninstall these modules. opts is an Object of options cordova fetch handles. Currently, fetch only support the save option. eg. {'save':true}