2.0.0 ā€¢ Published 6 years ago

project-bin-path v2.0.0

Weekly downloads
4,416
License
MIT
Repository
github
Last release
6 years ago

project-bin-path

build description

Find path to local bin of Node.js or NPM package

Inspired by sindresorhus/pkg-dir

Install:

npm install project-bin-path

or

yarn add project-bin-path

Usage:

Project structure

šŸ“ Users/
  šŸ“ ajaynarainmathur/
      šŸ“ test-project/
          šŸ“ node_modules/
              šŸ“ .bin/
          šŸ“ƒ package.json
              šŸ“ dist/
                  šŸ“ƒ foo.js
// foo.js
const projectBinPath = require('project-bin-path')

projectBinPath(__dirname).then(binPath => {
    console.log(binPath);
    // `/Users/ajaynarainmathur/test-project/node_modules/.bin`
});

Api

projectBinPath([cwd])

ā®‘ Returns a promise of path to .bin folder of the project or null if project is not found

projectBinPath.sync([cwd])

ā®‘ Returns the path to .bin of the project or null.

cwd

ā®‘ Directory to start from.

Type: string Default: process.cwd()

Use Cases

  1. When you need to get path to excutables in package ( not the project but of your local package ) just do projectBinPath(__dirname) => [...]/project/node_modules/your_package/node_modules/.bin

  2. When you need to get path to excutables in project ( project using you package* ) just do projectBinPath() => [...]/project/node_modules/.bin

License

MIT šŸ» Ajay Narain Mathur

2.0.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.0

6 years ago