resolve-dep

Return an array of resolved filepaths or directories for named npm modules. Wildcard (glob) patterns can be used.

npm install resolve-dep
132 downloads in the last day
988 downloads in the last week
4 962 downloads in the last month

resolve-dep NPM version

Return an array of resolved filepaths for named npm module dependencies. Wildcard (glob) patterns can be used.

BREAKING CHANGES IN 0.2.0: Please read the Release History!

Use in node projects (var load = require('resolve-dep').filter('*')), or filter directly into your project's Grunt config data using templates (<%= _.load("foo") %>).

Getting started

Install with npm: npm i resolve-dep --save

var resolve = require('resolve-dep');
resolve.filter('grunt');
// => ['node_modules/grunt/lib/grunt.js']

resolve.dirname('grunt');
// => ['node_modules/grunt']

API

// Resolve filepaths for dependencies
filter(pattern)

// Resolve filepaths for devDependencies
filterDev(pattern)

// Resolve filepaths for peer dependencies
filterPeer(pattern)

// Resolve filepaths for all dependencies
filterAll(pattern)

Resolve dirnames for dependencies:

// Resolve dirname for dependencies
dirname(pattern)

// Resolve dirname for devDependencies
dirnameDev(pattern)

// Resolve dirname for peerDependencies
dirnamePeer(pattern)

// Resolve dirname for both dependencies and devDependencies
dirnameAll(pattern)
// => ['node_modules/foo']

Usage examples

// Resolve filepaths to all dependencies from package.json
require('resolve-dep').filter('*');

// Resolve filepaths to all devDependencies
require('resolve-dep').filterDev('*');

// Resolve filepaths to both dependencies and devDependencies
require('resolve-dep').filterAll('*'));

Interface changes!

As of v0.2.0, the following methods have been renamed (left = old, right = new):

  • resolve.dep / resolve.load: => resolve.filter
  • resolve.dev / resolve.loadDev: => resolve.filterDev
  • resolve.all / resolve.loadAll: => resolve.filterAll
  • resolve.depDirname: => resolve.dirname
  • resolve.devDirname: => resolve.dirnameDev
  • resolve.allDirname: => resolve.dirnameAll

Aliases are still available but will be removed in 0.3.0.

More examples →

Contributing

Find a bug? Have a feature request? Please create an Issue.

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt, and build the documentation with grunt-readme.

Pull requests are also encouraged, and if you find this project useful please consider "starring" it to show your support! Thanks!

Author

Jon Schlinkert

Brian Woodward

Also, thank you to @tkellen for the excellent matchdep, which is used for filtering dependencies.

Release History

  • 2014-01-07 v0.2.0 Refactored completely.
  • 2013-09-07 v0.1.0 First commit.

License

Copyright (c) 2014 Jon Schlinkert, contributors. Released under the MIT license


This file was generated by grunt-readme on Saturday, January 11, 2014.

npm loves you