
Product
Introducing Custom Tabs for Org Alerts
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.
resolve-modules
Advanced tools
Resolves local and global npm modules that match specified patterns, and returns a configuration object for each resolved module.
Resolves local and global npm modules that match specified patterns, and returns a configuration object for each resolved module.
Install with npm:
$ npm install resolve-modules --save
var Resolver = require('resolve-modules');
var resolver = new Resolver();
Iterates over npm-paths and emits file for every resolved filepath, and match for files that match any specified matchers. Paths are cached in memory using a few different objects:
cache.paths: array of absolute directory and file pathscache.names: object of vinyl files, where file.name is the object key. file.name is the basename of the filepath, but it's aliased as name so we can use it without touching the getters/setters on the vinyl file.cache.files: array of vinyl filesParams
options {Object}: Specify a cache to use on options.cache.Example
var resolver = new Resolver();
resolver.resolve();
console.log(resolver);
Iterates over npm-paths and returns an array of vinyl files that match any provided matchers. Also emits file for all files, and match for matches. Additionally, paths are cached on the first call to .resolve so that any subsequent calls during the same process will use the cached filepaths instead of hitting the file system again. You can force .resolve to hit the file system again by deleting or nulling resolver.cache.dirs.
Params
fn {Function|String|Array|RegExp}: Optionally specify a matcher value.options {Object}returns {Array}: Returns an array of vinyl files.Example
resolver.match('verb', function(basename, file) {
return basename === 'verb';
});
// matches
console.log(resolver.resolve());
// all cached paths
console.log(resolver);
Find a filepath where file.basename exactly matches the given name. This method is standalone and does not require use of the .resolve method or matchers.
Params
name {String}: Basename of the file to match.returns {String|undefined}: Returns the absolute filepath if a match is found, otherwise undefined.Example
var filepath = resolver.find('foo');
Define a matcher to use for matching files when the resolve method is called. If a string or array of strings is passed, strict equality is used for comparisons with file.name.
Params
name {String|Function|Array|RegExp}: Optionally provide name to emit when a match is found, a matcher function, string to match, array of strings, or regex.val {String|Function|Array|RegExp}: Matcher function, string to match, array of strings, or regex.options {Object}: If a string is passed, options may be passed to micromatch to convert the string to regex.returns {Object}: Returns the instance for chaining.Example
resolver.match('foo');
Define a matcher to use for matching files when the resolve method is called. If a string or array of strings is passed, any file.name that contains the given string or strings will return true.
Params
name {String|Function|Array|RegExp}: Optionally provide name to emit when a match is found, a matcher function, string to match, array of strings, or regex.val {String|Function|Array|RegExp}: Matcher function, string to match, array of strings, or regex.options {Object}: If a string is passed, options may be passed to micromatch to convert the string to regex.returns {Object}: Returns the instance for chaining.Example
resolver.contains('foo');
Resolve sub-directories from npm-paths (does not recurse). This method probably doesn't need to be used directly, but it's exposed in case you want to customize behavior.
Params
fn {Function}: Optionally specify a filter function to use on filepaths. If provided, the function will be called before any matchers are called. basename and file are exposed to the filter function as arguments, where file is an instance of vinyl.returns {Object}: Returns the cache.Events
emits: ignore when a file is removed.Example
resolver.resolveDirs(function(basename, file) {
return !/foo/.test(file.path);
});
You might also be interested in these projects:
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Generate readme and API documentation with verb:
$ npm install verb && npm run docs
Or, if verb is installed globally:
$ verb
Install dev dependencies:
$ npm install -d && npm test
Jon Schlinkert
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on May 16, 2016.
FAQs
Resolves local and global npm modules that match specified patterns, and returns a configuration object for each resolved module.
The npm package resolve-modules receives a total of 23 weekly downloads. As such, resolve-modules popularity was classified as not popular.
We found that resolve-modules demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.

Product
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.

Security News
Chrome 144 introduces the Temporal API, a modern approach to date and time handling designed to fix long-standing issues with JavaScript’s Date object.