source: frontend/node_modules/npm-run-path/readme.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.9 KB
Line 
1# npm-run-path [![Build Status](https://travis-ci.org/sindresorhus/npm-run-path.svg?branch=master)](https://travis-ci.org/sindresorhus/npm-run-path)
2
3> Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries
4
5In [npm run scripts](https://docs.npmjs.com/cli/run-script) you can execute locally installed binaries by name. This enables the same outside npm.
6
7
8## Install
9
10```
11$ npm install npm-run-path
12```
13
14
15## Usage
16
17```js
18const childProcess = require('child_process');
19const npmRunPath = require('npm-run-path');
20
21console.log(process.env.PATH);
22//=> '/usr/local/bin'
23
24console.log(npmRunPath());
25//=> '/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'
26
27// `foo` is a locally installed binary
28childProcess.execFileSync('foo', {
29 env: npmRunPath.env()
30});
31```
32
33
34## API
35
36### npmRunPath(options?)
37
38Returns the augmented path string.
39
40#### options
41
42Type: `object`
43
44##### cwd
45
46Type: `string`<br>
47Default: `process.cwd()`
48
49Working directory.
50
51##### path
52
53Type: `string`<br>
54Default: [`PATH`](https://github.com/sindresorhus/path-key)
55
56PATH to be appended.<br>
57Set it to an empty string to exclude the default PATH.
58
59##### execPath
60
61Type: `string`<br>
62Default: `process.execPath`
63
64Path to the current Node.js executable. Its directory is pushed to the front of PATH.
65
66This can be either an absolute path or a path relative to the [`cwd` option](#cwd).
67
68### npmRunPath.env(options?)
69
70Returns the augmented [`process.env`](https://nodejs.org/api/process.html#process_process_env) object.
71
72#### options
73
74Type: `object`
75
76##### cwd
77
78Type: `string`<br>
79Default: `process.cwd()`
80
81Working directory.
82
83##### env
84
85Type: `Object`
86
87Accepts 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.
88
89##### execPath
90
91Type: `string`<br>
92Default: `process.execPath`
93
94Path to the Node.js executable to use in child processes if that is different from the current one. Its directory is pushed to the front of PATH.
95
96This can be either an absolute path or a path relative to the [`cwd` option](#cwd).
97
98
99## Related
100
101- [npm-run-path-cli](https://github.com/sindresorhus/npm-run-path-cli) - CLI for this module
102- [execa](https://github.com/sindresorhus/execa) - Execute a locally installed binary
103
104
105---
106
107<div align="center">
108 <b>
109 <a href="https://tidelift.com/subscription/pkg/npm-npm-run-path?utm_source=npm-npm-run-path&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
110 </b>
111 <br>
112 <sub>
113 Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
114 </sub>
115</div>
Note: See TracBrowser for help on using the repository browser.