
Product
Rust Support in Socket Is Now Generally Available
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.
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.
This is a WIP.
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'});
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-cli on December 03, 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 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
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.

Research
Five coordinated Chrome extensions enable session hijacking and block security controls across enterprise HR and ERP platforms.