pax_global_header00006660000000000000000000000064127731461740014526gustar00rootroot0000000000000052 comment=4d956312d5da324c4eff435af7d80797f04f09e1
npm-run-path-2.0.2/000077500000000000000000000000001277314617400140555ustar00rootroot00000000000000npm-run-path-2.0.2/.editorconfig000066400000000000000000000002761277314617400165370ustar00rootroot00000000000000root = true
[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[{package.json,*.yml}]
indent_style = space
indent_size = 2
npm-run-path-2.0.2/.gitattributes000066400000000000000000000000351277314617400167460ustar00rootroot00000000000000* text=auto
*.js text eol=lf
npm-run-path-2.0.2/.gitignore000066400000000000000000000000151277314617400160410ustar00rootroot00000000000000node_modules
npm-run-path-2.0.2/.travis.yml000066400000000000000000000000531277314617400161640ustar00rootroot00000000000000language: node_js
node_js:
- '6'
- '4'
npm-run-path-2.0.2/index.js000066400000000000000000000013761277314617400155310ustar00rootroot00000000000000'use strict';
const path = require('path');
const pathKey = require('path-key');
module.exports = opts => {
opts = Object.assign({
cwd: process.cwd(),
path: process.env[pathKey()]
}, opts);
let prev;
let pth = path.resolve(opts.cwd);
const ret = [];
while (prev !== pth) {
ret.push(path.join(pth, 'node_modules/.bin'));
prev = pth;
pth = path.resolve(pth, '..');
}
// ensure the running `node` binary is used
ret.push(path.dirname(process.execPath));
return ret.concat(opts.path).join(path.delimiter);
};
module.exports.env = opts => {
opts = Object.assign({
env: process.env
}, opts);
const env = Object.assign({}, opts.env);
const path = pathKey({env});
opts.path = env[path];
env[path] = module.exports(opts);
return env;
};
npm-run-path-2.0.2/license000066400000000000000000000021371277314617400154250ustar00rootroot00000000000000The MIT License (MIT)
Copyright (c) Sindre Sorhus (sindresorhus.com)
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.
npm-run-path-2.0.2/package.json000066400000000000000000000013621277314617400163450ustar00rootroot00000000000000{
"name": "npm-run-path",
"version": "2.0.2",
"description": "Get your PATH prepended with locally installed binaries",
"license": "MIT",
"repository": "sindresorhus/npm-run-path",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"npm",
"run",
"path",
"package",
"bin",
"binary",
"binaries",
"script",
"cli",
"command-line",
"execute",
"executable"
],
"dependencies": {
"path-key": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
},
"xo": {
"esnext": true
}
}
npm-run-path-2.0.2/readme.md000066400000000000000000000035421277314617400156400ustar00rootroot00000000000000# npm-run-path [](https://travis-ci.org/sindresorhus/npm-run-path)
> Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries
In [npm run scripts](https://docs.npmjs.com/cli/run-script) you can execute locally installed binaries by name. This enables the same outside npm.
## Install
```
$ npm install --save npm-run-path
```
## Usage
```js
const childProcess = require('child_process');
const npmRunPath = require('npm-run-path');
console.log(process.env.PATH);
//=> '/usr/local/bin'
console.log(npmRunPath());
//=> '/Users/sindresorhus/dev/foo/node_modules/.bin:/Users/sindresorhus/dev/node_modules/.bin:/Users/sindresorhus/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/usr/local/bin'
// `foo` is a locally installed binary
childProcess.execFileSync('foo', {
env: npmRunPath.env()
});
```
## API
### npmRunPath([options])
#### options
##### cwd
Type: `string`
Default: `process.cwd()`
Working directory.
##### path
Type: `string`
Default: [`PATH`](https://github.com/sindresorhus/path-key)
PATH to be appended.
Set it to an empty string to exclude the default PATH.
### npmRunPath.env([options])
#### options
##### cwd
Type: `string`
Default: `process.cwd()`
Working directory.
##### env
Type: `Object`
Accepts an object of environment variables, like `process.env`, and modifies the PATH using the correct [PATH key](https://github.com/sindresorhus/path-key). Use this if you're modifying the PATH for use in the `child_process` options.
## Related
- [npm-run-path-cli](https://github.com/sindresorhus/npm-run-path-cli) - CLI for this module
- [execa](https://github.com/sindresorhus/execa) - Execute a locally installed binary
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
npm-run-path-2.0.2/test.js000066400000000000000000000004531277314617400153740ustar00rootroot00000000000000import path from 'path';
import test from 'ava';
import m from './';
test(t => {
t.is(
m({path: ''}).split(path.delimiter)[0],
path.join(__dirname, 'node_modules/.bin')
);
t.is(
m.env({env: {PATH: 'foo'}}).PATH.split(path.delimiter)[0],
path.join(__dirname, 'node_modules/.bin')
);
});