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 
which the heck directions
Answering this questions:
- Was the script run from a bin?
- There is some config file asociated to it?
- What is the main or/and global
node_modulesdirectory?- If so fetch me some fields from that package
install
$ npm install --save whechusage
var whech = require('whech');
whech.packageFields = ['version'];
whech('which', function(err, env){
if(err) throw err;
console.log(env);
// =>
// { name: 'which',
// extension: '.js',
// which: '/usr/bin/which',
// runFromBin: false,
// configFile: [Error: not found],
// mainDir: '/home/jcm/code/whech/node_modules',
// globalDir: '/home/jcm/npm/lib/node_modules',
// cliPackage: { [Error: Cannot find module] code: 'MODULE_NOT_FOUND' },
// modulePackage: { version: '1.0.5' } }
});documentation
var whech = require('whech')
The function returned by the package is asynchronous.
To use the sync version take whech.sync.
To specify what properties you want from the cli and module packages change
whech.packageFields by default whech.packageFields = ['version'].
async
whech(spec, callback)
spec
type string or object
- If spec is a string it becomnes
env.name(see below). - If spec is an object overrides the default properties of
env(see below).
If something is not found instead of throwing an error is assigned to that env key value.
callback(err, env)
callback is called with the last error if there was one.
env properties:
- name: the name of the spec
- which: first instance of an executable in the PATH
- runFromBin: wether or not
process.argvcontainsenv.which - configFile:
spec.configFileif was given and if notenv.name+'file'+env.extension. - mainDir:
npm.dir - globalDir:
npm.globalDir - cliPackage:
require(path.join(env.globalDir, env.name, 'package')) - modulePackage:
require(path.join(env.mainDir, env.name, 'package'))
test
$ npm testtodo
- Make better tests
- Review and see if there is something missing