JSPM

  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q51729F
  • License MIT

which the heck directions

Package Exports

  • whech

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (whech) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

whech buildNPM version

install - documentation - license

which the heck directions for

  • Was the script run from a bin?
  • There is some config file asociated to it?
  • What is the main or/and global node_modulesdirectory?
  • Get me some fields of their the local and global packages

install

$ npm install --save whech

usage

var whech = require('whech');

whech.packageFields = ['version'];

whech('which', function(err, env){
  if(err) throw err;
  console.log(env);
  // =>
  // { name: 'which',
  //   which: '/usr/bin/which',
  //   runFromBin: false,
  //   configFile: [Error: not found],
  //   localDir: '/home/jcm/code/whech/node_modules',
  //   globalDir: '/home/jcm/npm/lib/node_modules',
  //   globalPackage: { [Error: Cannot find module] code: 'MODULE_NOT_FOUND' },
  //   localPackage: { version: '1.0.5' } }
});

documentation

The module.exports a function

var whech = require('whech')

which is asynchronous. To use the sync version take whech.sync.

whech

function whech(string|object spec, function callback)

arguments

  • spec type string|object, when string becomens spec.name
  • callback function to called with the last error if there was one

Errors are attached to spec properties instead of throwing.

spec properties

  • name: the name given as a string or object property
  • which: first instance of an executable in the PATH
  • runFromBin: wether or not process.argv contains which
  • configFile: configFile if given, or name + file + '.js'.
  • localDir: if wasn't given, the global dir where node_modules are installed
  • globalDir: if wasn't given, the local dir where node_modules are installed
  • localPackage: require(path.join(name, 'package'))
  • globalPackage: require(path.join(localDir, name, 'package'))

whech.sync

function whechSync(string|object spec)

arguments

  • spec, type string|object, the same as the async version

returns

  • spec with same properties listed above

test

npm test

todo

  • More tests
  • Review and see if there is something missing

license

LICENSE