
Security News
Federal Government Rescinds Software Supply Chain Mandates, Makes SBOMs Optional
The U.S. government is rolling back software supply chain mandates, shifting from mandatory SBOMs and attestations to a risk-based approach.
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.
(TOC generated by verb)
Install with npm
$ npm i resolve-modules --save
var Resolver = require('resolve-modules');
var resolver = new Resolver({
module: 'generate'
});
resolver.resolve({
cwd: process.cwd(),
pattern: 'generate-*/generate.js'
});
When the search pattern finds a match, a config event is emitted:
resolver.on('config', function(config) {
// do stuff with "config"
});
The config object that is emitted looks something like this:
{
options:
{ realpath: true,
cwd: '/usr/local/lib/node_modules',
module: 'generate',
pattern: 'generate-*/generator.js',
configCwd: '/usr/local/lib/node_modules/generate-foo',
context: {} },
cache:
{ name: 'generate-foo',
dirname: '/usr/local/lib/node_modules/generate-foo',
root: '/usr/local/lib/node_modules/generate-foo',
filename: 'generator.js',
cwd: '/usr/local/lib/node_modules/generate-foo',
pkg: '/usr/local/lib/node_modules/generate-foo/package.json',
relative: '',
alias: 'foo' },
path: '/usr/local/lib/node_modules/generate-foo/generator.js',
fn: [Getter/Setter],
filename: [Getter/Setter],
realpath: [Getter],
cwd: [Getter/Setter],
root: [Getter/Setter],
dirname: [Getter/Setter],
relative: [Getter/Setter],
name: [Getter/Setter],
alias: [Getter/Setter],
pkg: [Getter/Setter],
main: [Getter/Setter],
module:
Mod {
name: 'generate',
configCwd: undefined,
path: '/usr/local/lib/node_modules/generate/index.js',
realpath: [Getter],
pkg: [Getter],
fn: [Getter] } }
Create an instance of Resolver with options. The only required option is module, which is the name of the module that will be used for creating instances for config files by the resolve method.
For example, [generate][], the project generator, would be the "module",
and individual generators (generator.js files) would be the "config" files.
Params
options {Object}Example
var resolver = new Resolver({
module: 'generate'
});
Searches for config files that match the given glob patterns and, when found, emits config with details about the module and environment, such as absolute path, cwd, path to parent module, etc.
Params
patterns {String|Array|Object}: Glob pattern(s) or options object. If options, the pattern property must be defined with a glob pattern.options {Object}returns {Object}: Returns the resolver instance, for chaining.Example
var resolver = new Resolver({
module: 'generate'
});
resolver.on('config', function(config, mod) {
// `config` is an object with fully resolved file paths.
// Config also has a `fn` getter that returns the contents of
// the config file. Using the "generate" analogy above, this would
// be a "generator.js" config file
// `mod` (module) is a similar object, but for the "parent"
// module. Using the generate analogy above, this would be an installation
// "generate", either installed locally to the generator, or as a global
// npm module
});
resolver
.resolve('generator.js', {cwd: 'foo'})
.resolve('generator.js', {cwd: 'bar'})
.resolve('generator.js', {cwd: 'baz'});
Return a new env (environment) object with config, module
and user properties.
Params
fp {String}: The starting filepath for the configcwd {String}: The user (process) cwdoptions {Object}returns {Object}Create a new Mod with the given options
Params
options {Object}Example
var mod = new Mod(options);
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb on December 16, 2015.
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 17 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.

Security News
The U.S. government is rolling back software supply chain mandates, shifting from mandatory SBOMs and attestations to a risk-based approach.

Security News
crates.io adds a Security tab backed by RustSec advisories and narrows trusted publishing paths to reduce common CI publishing risks.

Research
/Security News
A Chrome extension claiming to hide Amazon ads was found secretly hijacking affiliate links, replacing creators’ tags with its own without user consent.