$ cnpm install npm-file
Specify a path within an npm package: download and extract it, returning a local path for reading.
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 = require('glsl-resolve')
var cachedir = __dirname + '/.cache'
var getnpm = require('npm-file')(cachedir, resolve)
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 *
or latest
.filename
: the module in the package to retrieve. Uses the previously defined resolve
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.MIT. See LICENSE.md for details.
Copyright 2014 - 2017 © taobao.org |