resolve-bin

Resolves the full path to the bin file of a given package by inspecting the "bin" field in its package.json.

npm install resolve-bin
5 downloads in the last week
35 downloads in the last month

resolve-bin build status

Resolves the full path to the bin file of a given package by inspecting the "bin" field in its package.json.

var resolveBin = require('resolve-bin');

// package.json: "bin": "bin/tap.js"
resolveBin('tap', function (err, bin) {
  if (err) return console.error(err);
  console.log(bin);  
});

// => [..]/resolve-bin/node_modules/tap/bin/tap.js

Installation

npm install resolve-bin

API

resolveBin(name, cb)

/**
 * Resolves the full path to the bin file of a given package by inspecting the "bin" field in its package.json. 
 *
 * @name resolveBin
 * @function
 * @param name {String} module name, i.e. 'tap'
 * @param cb {Function} called back with the full path to the bin file of the module or an error if it couldn't be resolved
 */

License

MIT

npm loves you