whech
v0.7.6
Published
which the heck directions
Downloads
35
Maintainers
Readme
whech 

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
usage
var whech = require('whech');
whech.ext = '.js';
whech('which', function(err, spec){
if(err) throw err;
console.log(spec);
// =>
// { 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
spectype string or object with a name property that is a stringcallbacktype function to be called with the lasterrorandspec
Errors are attached to spec a property instead of throwing.
spec properties
exttype string, the extension of the configFilenametype string the name given as a string or object propertywhichtype string first instance of an executable in the PATHrunFromBintype boolean, wether or notprocess.argvcontainswhichconfigFiletype string,configFileif givenlocalDirtype string, the global dir where node_modules are installedglobalDir: type string, the local dir where node_modules are installedlocalPackage:require(path.join(name, 'package'))globalPackage:require(path.join(localDir, name, 'package'))
defaults
configfilewill default toname + 'file' + (spec.ext || '.js')
whech.sync
function whechSync(string|object spec)arguments
spec, type string|object, the same as the async version
returns
specwith same properties listed above
install
With npm
npm install whechtest
npm testtodo
- [ ] More tests
- [ ] Review and see if there is something missing
