Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ajaymathur/project-bin-path
Find path to local bin of Node.js or NPM package :rocket:
https://github.com/ajaymathur/project-bin-path
Last synced: 19 days ago
JSON representation
Find path to local bin of Node.js or NPM package :rocket:
- Host: GitHub
- URL: https://github.com/ajaymathur/project-bin-path
- Owner: ajaymathur
- License: mit
- Created: 2017-11-25T21:26:53.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-25T08:43:29.000Z (almost 2 years ago)
- Last Synced: 2024-10-25T20:34:32.925Z (21 days ago)
- Language: JavaScript
- Homepage:
- Size: 14.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
## project-bin-path
![build description](https://travis-ci.org/ajaymathur/project-bin-path.svg?branch=master)
> Find path to local bin of Node.js or NPM package
***Inspired by [sindresorhus/pkg-dir](https://github.com/sindresorhus/pkg-dir)***
### Install:
`npm install project-bin-path`
or
`yarn add project-bin-path`
### Usage:
Project structure
```text
📁 Users/
📁 ajaynarainmathur/
📁 test-project/
📁 node_modules/
📁 .bin/
📃 package.json
📁 dist/
📃 foo.js
``````javascript
// 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](https://github.com/ajaymathur)