# base-resolver

> 'base-methods' plugin for resolving and loading globally installed npm modules.

Latest version **0.3.4** (published 2015-12-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install base-resolver
pnpm add base-resolver
yarn add base-resolver
bun add base-resolver
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.4 |
| Published | 2015-12-14 |
| First published | 2015-11-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert |
| Keywords | base, resolver |

## Links

- npm: https://www.npmjs.com/package/base-resolver
- Repository: https://github.com/jonschlinkert/base-resolver
- Issues: https://github.com/jonschlinkert/base-resolver/issues
- npm.io page: https://npm.io/package/base-resolver

## Dependencies (3)

- [lazy-cache](https://npm.io/package/lazy-cache.md) ^1.0.2
- [extend-shallow](https://npm.io/package/extend-shallow.md) ^2.0.1
- [resolve-modules](https://npm.io/package/resolve-modules.md) ^0.3.3

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 0.3.4 (latest) — 2015-12-14
- 0.3.3 — 2015-12-14
- 0.3.2 — 2015-12-05
- 0.3.1 — 2015-12-05
- 0.3.0 — 2015-12-05
- 0.2.1 — 2015-12-04
- 0.2.0 — 2015-12-03
- 0.1.2 — 2015-11-19
- 0.1.1 — 2015-11-19
- 0.1.0 — 2015-11-19

## README

# base-resolver [![NPM version](https://img.shields.io/npm/v/base-resolver.svg)](https://www.npmjs.com/package/base-resolver) [![Build Status](https://img.shields.io/travis/jonschlinkert/base-resolver.svg)](https://travis-ci.org/jonschlinkert/base-resolver)

> 'base-methods' plugin for resolving and loading globally installed npm modules.

## Install

Install with [npm](https://www.npmjs.com/)

```sh
$ npm i base-resolver --save
```

## Usage

```js
var resolver = require('base-resolver');
```

### Example

In two steps, the following example shows how we would use `base-resolver` with a custom `Generate` application that is built on top of [base-methods][].

**Step 1: Setup**

The following example shows how we might begin creating a basic project generator from [base-methods][]. More specifically, this shows how we might register and cache generators.

```js
var resolver = require('base-resolver');
var Generate = require('base-methods');

// register a "global" plugin, to initialize the `generators` 
// object, and decorate a `register` method (as an alternative 
// to inheriting base-methods or other more complicated approaches)
Generate.use(function(app) {
  app.generators = {};
  app.define('register', function(key, config) {
    this.generators[key] = config;
    return this;
  });
});

// register `resolver` as a global plugin
Generate.use(resolver('generate'));
```

**Step 2**

Intantiate the custom application we just created, and search for generators!

```js
var generate = new Generate();

// setup a listener that will register generators (
// `config`s) as they're emitted
generate.on('config', function(config) {
  console.log('registered:', config.alias);
  generate.register(config.alias, config);
});

// find configs!
generate
  .resolve('generate-*/generator.js', {
    cwd: require('global-modules')
  });
  .resolve('generate-*/generator.js', {
    cwd: process.cwd()
  });
```

## API

**Params**

* `name` **{String}**: Optionally specify a namespace for storing resolved configs.
* `options` **{Object}**: Options to pass to [matched](https://github.com/jonschlinkert/matched)
* `option.patterns` **{String|Array}**: Glob patterns to search
* `option.cwd` **{String}**: The starting directory to search from
* `returns` **{Object}**

**Example**

```js
resolver.on('config', function(config) {
  // do stuff with "config"
});

resolver
  .resolve('foo', {pattern: 'generator.js', cwd: 'foo'})
  .resolve('bar', {pattern: 'generator.js', cwd: 'bar'})
  .resolve('baz', {pattern: 'generator.js', cwd: 'baz'})
```

## Related projects

* [global-modules](https://www.npmjs.com/package/global-modules): The directory used by npm for globally installed npm modules. | [homepage](https://github.com/jonschlinkert/global-modules)
* [matched](https://www.npmjs.com/package/matched): Adds array support to node-glob, sync and async. Also supports tilde expansion (user home) and… [more](https://www.npmjs.com/package/matched) | [homepage](https://github.com/jonschlinkert/matched)
* [npm-paths](https://www.npmjs.com/package/npm-paths): Returns an array of unique "npm" directories based on the user's platform and environment. | [homepage](https://github.com/jonschlinkert/npm-paths)
* [resolve-modules](https://www.npmjs.com/package/resolve-modules): Resolves local and global npm modules that match specified patterns, and returns a configuration object… [more](https://www.npmjs.com/package/resolve-modules) | [homepage](https://github.com/jonschlinkert/resolve-modules)

## Running tests

Install dev dependencies:

```sh
$ npm i -d && npm test
```

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/base-resolver/issues/new).

## Author

**Jon Schlinkert**

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

## License

Copyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert)
Released under the MIT license.

***

_This file was generated by [verb](https://github.com/verbose/verb) on December 14, 2015._

---
_Source: https://npm.io/package/base-resolver · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
