which-promise
Version:
Promisified version of node-which
49 lines (33 loc) • 1.83 kB
Markdown
# which-promise
[](https://www.npmjs.com/package/which-promise)
[](https://travis-ci.org/shinnn/which-promise)
[](https://ci.appveyor.com/project/ShinnosukeWatanabe/which-promise)
[](https://coveralls.io/r/shinnn/which-promise)
[](https://david-dm.org/shinnn/which-promise)
[](https://david-dm.org/shinnn/which-promise#info=devDependencies)
[Promisified](https://promise-nuggets.github.io/articles/07-wrapping-callback-functions.html) version of [node-which](https://github.com/npm/node-which):
> Finds the first instance of a specified executable in the PATH environment variable.
```javascript
const whichPromise = require('which-promise');
whichPromise('ls').then(resolvedPath => {
resolvedPath; //=> '/bin/ls'
});
whichPromise('ls', {path: './'}).catch(err => {
err.message; //=> 'not found: ls'
});
```
## Installation
[Use npm.](https://docs.npmjs.com/cli/install)
```
npm install which-promise
```
## API
```javascript
const whichPromise = require('which-promise');
```
### whichPromise(*cmd* [, *options*])
*cmd*: `String` (directly passed to node-which's first argument)
*options*: `Object` (used as node-which [options](https://github.com/npm/node-which/blob/5d832a3d32b21a7f110771a3c14d5e8ee90d6706/which.js#L40))
Return: `Object` ([Promise](https://promisesaplus.com/))
## License
[The Unlicense](./LICENSE)