# helper-resolve

> Template helper to resolve the path to a file in node_modules. This is mostly useful during development.

Latest version **0.3.1** (published 2015-04-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install helper-resolve
pnpm add helper-resolve
yarn add helper-resolve
bun add helper-resolve
```

## 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.1 |
| Published | 2015-04-19 |
| First published | 2015-02-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert |

## Links

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

## Dependencies (3)

- [chalk](https://npm.io/package/chalk.md) ^1.0.0
- [relative](https://npm.io/package/relative.md) ^3.0.0
- [clone-deep](https://npm.io/package/clone-deep.md) ^0.1.1

## Recent versions

- 0.3.1 (latest) — 2015-04-19
- 0.3.0 — 2015-04-19
- 0.2.0 — 2015-02-27
- 0.1.2 — 2015-02-23
- 0.1.1 — 2015-02-22
- 0.1.0 — 2015-02-15

## README

# helper-resolve [![NPM version](https://badge.fury.io/js/helper-resolve.svg)](http://badge.fury.io/js/helper-resolve)  [![Build Status](https://travis-ci.org/jonschlinkert/helper-resolve.svg)](https://travis-ci.org/jonschlinkert/helper-resolve) 

> Template helper to resolve the path to a file in node_modules. This is mostly useful during development.

Refactored to return an object, so the results of the helper can be passed to other helpers that require more information.

## Install with [npm](npmjs.org)

```bash
npm i helper-resolve --save
```

## Usage

```js
var resolve = require('helper-resolve');
var Handlebars = require('handlebars');

handlebars.registerHelper('resolve', function (name, key) {
  return resolve.sync(fp)[typeof key === 'string' ? key : 'main'];
});
handlebars.compile('<script src=\"{{resolve "jquery" "main"}}\"></script>')().
//=> '<script src="node_modules/jquery/dist/jquery.js"></script>'

handlebars.compile('{{resolve "jquery" "homepage"}}')().
//=> 'http://jquery.com'
```

## Assemble example

Register the helper with [assemble] v0.6.x to use with any template engine:

```js
var assemble = require('assemble');
assemble.helper('resolve', function (name, key) {
  return resolve.sync(fp)[typeof key === 'string' ? key : 'main'];
});
```

**async helper**

```js
assemble.asyncHelper('resolve', function (name, key, cb) {
  if (typeof key === 'function') {
    cb = key;
    key = 'main';
  }

  resolve(name, function (err, res) {
    cb(null, res[key]);
  });
});
```

## Run tests
Install dev dependencies:

```bash
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/helper-resolve/issues)

## Author

**Jon Schlinkert**

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

## License
Copyright (c) 2015 Jon Schlinkert  
Released under the MIT license

***

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 19, 2015._

[assemble]: https://github.com/assemble/assemble

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