real-executable-paths-callback

1.0.0 • Public • Published

real-executable-paths-callback

NPM version Build Status Build status Coverage Status Dependency Status devDependency Status

Callback-style version of real-executable-paths:

Find all the resolved paths of the given executable in the PATH, with expanding all symbolic links

const realExecutablePathsCallback = require('real-executable-paths-callback');
const which = require('which');
 
which('zsh', {all: true}, (err, paths) => {
  paths; //=> ['/usr/local/bin/zsh', '/bin/zsh']
});
 
realExecutablePathsCallback('zsh', (err, binPath) => {
  binPath; //=> ['/usr/local/Cellar/zsh/5.1.1/bin/zsh', '/bin/zsh']
});

Installation

Use npm.

npm install real-executable-paths-callback

API

const realExecutablePathsCallback = require('real-executable-paths-callback');

realExecutablePathsCallback(fileName [, options], callback)

fileName: String (an executable name in the PATH)
options: Object
callback: Function (called after the paths are resolved)

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

options

Options except for all option are used as which options, and option.cache is used as cache of fs.realpath.

const realExecutablePathsCallback = require('real-executable-paths-callback');
 
realExecutablePathsCallback('foo', {
  path: 'bar:baz',
  cache: {
    'bar/foo': '/path/to/qux',
    'baz/foo': '/path/to/quux'
  }
}, (err, resolvedPaths) => {
  resolvedPaths; //=> ['/path/to/qux', '/path/to/quux']
});

Related projects

License

Copyright (c) 2015 Shinnosuke Watanabe

Licensed under the MIT License.

Dependencies (2)

Dev Dependencies (5)

Package Sidebar

Install

npm i real-executable-paths-callback

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • shinnn