3.1.0 • Published 11 years ago
resolve-recurse v3.1.0
node-resolve-recurse
Recursively resolve the paths of dependent node packages
Given the directory of a module (including the current module), generate a object with the names, versions, and paths of all modules that this module depends on, recursively.
##Installation
npm install resolve-recurse##Usage
var resolve = require('resolve-recurse');
resolve(options, function(err, dependencies) {
console.log(dependencies);
});options is an Object containing up to 3 properties, outlined below.
If you do not pass options to resolve, it will simply assume all default options.
resolve will pass an object to the callback function in the form:
{
"name": "test-module",
"path": "/proj/node-resolve-recurse/test/test-module",
"allowedVersion": "^0.0.1",
"actualVersion": "0.0.1",
"dependencies": [
{
"name": "test-submodule-1",
"path": "/proj/node-resolve-recurse/test/test-module/node_modules/test-submodule-1",
"allowedVersion": "^0.0.1",
"actualVersion": "0.0.1",
"dependencies": []
}, {
"name": "test-submodule-2",
"path": "/proj/node-resolve-recurse/test/test-module/node_modules/test-submodule-2",
"allowedVersion": "^1.2.3",
"actualVersion": "1.2.3",
"dependencies": []
}, {
"name": "test-submodule-3",
"path": "/proj/node-resolve-recurse/test/test-module/node_modules/test-submodule-3",
"allowedVersion": "^4.7.9",
"actualVersion": "4.7.9",
"dependencies": [
{
"name": "test-sub-submodule",
"path": "/proj/node-resolve-recurse/test/test-module/node_modules/test-sub-submodule",
"allowedVersion": "^0.0.3",
"actualVersion": "0.0.3",
"dependencies": []
}
]
}
]
}###Options
properties-[String]- Properties in the
package.jsonto look for dependencies. - defaults to
['dependencies']
- Properties in the
path-String- Path to an npm module to start searching for dependencies.
- defaults to
__filename
relative-String- Path to the file that
pathshould be resolved relative to. Useful if you are writing a library making use ofresolve-recurse. - Only used if
pathis specified. - defaults to
__filename
- Path to the file that
filter-Function(pkg)- Determine whether or not to resolve a dependency.
- If this is a Function, it will be called with
pkg, an object representation of the package.json file of each dependency, and is expected to returntrueto continue resolving, orfalseto ignore it. - Defaults to
null(no filter)
