NPM.downloadPackage()

Stream the tarball for the NPM package+version to disk, then extract it.

Usage

Hover over inputs/exits for more info.

var NPM = require('machinepack-npm');


// Stream the tarball for the NPM package+version to disk, then extract it.

NPM.downloadPackage({

name: 'isarray',

version: '0.0.1',

registry: 'https://your-private-registry.npmjs.org',

destination: '/Users/mikermcneil/dogfood-promo-site',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// Could not extract (untar) the tarball downloaded from NPM.

untarFailed: function () {

 

},

// Could not unzip the `.tar.gz` file downloaded from NPM.

unzipFailed: function () {

 

},

// Could not download the package from npm- perhaps the registry URL is incorrect?

downloadFailed: function () {

 

},

// Passed an invalid semantic version number. See https://docs.npmjs.com/misc/semver for details.

invalidSemVer: function () {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

name required

The name of the NPM package to fetch

'isarray'
version required

The version of the NPM package to fetch

'0.0.1'
registry

The URL of the NPM registry to use (defaults to the public npm registry)

'https://your-private-registry.npmjs.org'
destination

The absolute path where the package should be extracted.

'/Users/mikermcneil/dogfood-promo-site'

Exits

error

An unexpected error occurred.

untarFailed

Could not extract (untar) the tarball downloaded from NPM.

unzipFailed

Could not unzip the `.tar.gz` file downloaded from NPM.

downloadFailed

Could not download the package from npm- perhaps the registry URL is incorrect?

invalidSemVer

Passed an invalid semantic version number. See https://docs.npmjs.com/misc/semver for details.

success

OK.

'/var/folders/_s/347n05_x2rgb_0w6s6y0ytr00000gn/T/machinepack-phantomjscloud-0.1.2'