node-locate

0.0.4 • Public • Published

node-locate

Build Status Dependency Status Coverage Status NPM version

NPM

Table of Contents

Locate path to a command in your system. This module also keeps track of commands in node_modules folder.

Usage

As a command line tool

If you just want to use this utility as a command line tool, simply install this module with the -g flag:

$ npm install -g node-locate

Then you can use it as:

$ nlocate ls
/usr/local/bin/ls
$ nlocate non-existent  # this command does not exist
'non-existent' not found

As a module within another

In some cases you may need to use node-locate within some other module. This is as simple as:

var locate = require('node-locate');
 
try {
  var cmdPath = locate('some-command');
  console.log('found command at: ' + cmdPath);
} catch (e) {
  console.error('Unable to find command');
}

node-locate also supports the callback pattern which lets you avoid the ugly try-catch block:

locate('some-command', function(err, cmdPath) {
  if (err) {
    console.err('unable to find command');
  } else {
    console.log('found command at: ' + cmdPath);
  }
});

Contributing

Feel free to make a change and issue a pull request if you have a patch.

If you have a feature request or if you find a bug, please open a issue.

Author

Anshul Verma :: anshulverma :: @anshulverma

License

The MIT License (MIT)

Copyright (c) 2014 Anshul Verma

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package Sidebar

Install

npm i node-locate

Weekly Downloads

3

Version

0.0.4

License

none

Last publish

Collaborators

  • anshulverma