npm-file
Specify a path within an npm package: download and extract it, returning a local path for reading
Last updated 6 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install npm-file 
SYNC missed versions from official npm registry.

npm-file experimental

Specify a path within an npm package: download and extract it, returning a local path for reading.

Usage

NPM

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  = require('glsl-resolve')
var cachedir = __dirname + '/.cache'
var getnpm   = require('npm-file')(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 * 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.

License

MIT. See LICENSE.md for details.

Current Tags

  • 1.0.0                                ...           latest (6 years ago)

1 Versions

  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2017 © taobao.org |