3.0.0 • Published 6 years ago

real-executable-path-callback v3.0.0

Weekly downloads
464
License
ISC
Repository
github
Last release
6 years ago

real-executable-path-callback

npm version Build Status Build status Coverage Status

Callback-style version of real-executable-path:

Find the first instance of an executable in the PATH, with expanding all symbolic links

const realExecutablePathCallback = require('real-executable-path-callback');
const which = require('which');

which('npm', (err, binPath) => {
  binPath; //=> '/usr/local/bin/npm'
});

realExecutablePathCallback('npm', (err, binPath) => {
  binPath; //=> '/usr/local/lib/node_modules/npm/bin/npm-cli.js'
});

Installation

Use npm.

npm install real-executable-path-callback

API

const realExecutablePathCallback = require('real-executable-path-callback');

realExecutablePathCallback(binName , options, callback)

binName: string (an executable name in the PATH)
options: Object (node-which options except for all)
callback: Function (called after the path is resolved)

It finds the first instance of the given executable in the PATH environment variable, expands all symbolic links and resolves the canonicalized absolute pathname.

const realExecutablePathCallback = require('real-executable-path-callback');

realExecutablePathCallback('this_cmd_is_not_installed', err => {
  err.message; //=> 'not found: this_cmd_is_not_installed'
  err.code; //=> 'ENOENT'
});

Related project

License

ISC License © 2017 Shinnosuke Watanabe