npm-file
Specify a path within an npm package: download and extract it, returning a local path for reading.
Usage
get = npmfile(cache, resolve)
Returns a function you can use to get files from packages on npm. Takes the following arguments, both of which are optional:
cache
: the directory to store modules on the filesystem. Defaults to.npm-files
.resolve
: a custom module resolution function. Defaults to resolve, and expects the same function signature.
var resolve =var cachedir = __dirname + '/.cache'var getnpm = cachedir resolve
get(package, version, filename, got)
Retrieves a file from npm. Takes the following arguments:
package
: the name of the package on npm.version
: a semver version range. May also be a fixed version, or*
orlatest
.filename
: the module in the package to retrieve. Uses the previously definedresolve
function, so you can omit file extensions if you so please.got(err, path)
: is called when complete, returning the file path of the target module.
License
MIT. See LICENSE.md for details.