| 1 | declare namespace npmRunPath {
|
|---|
| 2 | interface RunPathOptions {
|
|---|
| 3 | /**
|
|---|
| 4 | Working directory.
|
|---|
| 5 |
|
|---|
| 6 | @default process.cwd()
|
|---|
| 7 | */
|
|---|
| 8 | readonly cwd?: string;
|
|---|
| 9 |
|
|---|
| 10 | /**
|
|---|
| 11 | PATH to be appended. Default: [`PATH`](https://github.com/sindresorhus/path-key).
|
|---|
| 12 |
|
|---|
| 13 | Set it to an empty string to exclude the default PATH.
|
|---|
| 14 | */
|
|---|
| 15 | readonly path?: string;
|
|---|
| 16 |
|
|---|
| 17 | /**
|
|---|
| 18 | Path 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.
|
|---|
| 19 |
|
|---|
| 20 | This can be either an absolute path or a path relative to the `cwd` option.
|
|---|
| 21 |
|
|---|
| 22 | @default process.execPath
|
|---|
| 23 | */
|
|---|
| 24 | readonly execPath?: string;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | interface ProcessEnv {
|
|---|
| 28 | [key: string]: string | undefined;
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | interface EnvOptions {
|
|---|
| 32 | /**
|
|---|
| 33 | Working directory.
|
|---|
| 34 |
|
|---|
| 35 | @default process.cwd()
|
|---|
| 36 | */
|
|---|
| 37 | readonly cwd?: string;
|
|---|
| 38 |
|
|---|
| 39 | /**
|
|---|
| 40 | 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.
|
|---|
| 41 | */
|
|---|
| 42 | readonly env?: ProcessEnv;
|
|---|
| 43 |
|
|---|
| 44 | /**
|
|---|
| 45 | Path to the current Node.js executable. Its directory is pushed to the front of PATH.
|
|---|
| 46 |
|
|---|
| 47 | This can be either an absolute path or a path relative to the `cwd` option.
|
|---|
| 48 |
|
|---|
| 49 | @default process.execPath
|
|---|
| 50 | */
|
|---|
| 51 | readonly execPath?: string;
|
|---|
| 52 | }
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | declare const npmRunPath: {
|
|---|
| 56 | /**
|
|---|
| 57 | Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries.
|
|---|
| 58 |
|
|---|
| 59 | @returns The augmented path string.
|
|---|
| 60 |
|
|---|
| 61 | @example
|
|---|
| 62 | ```
|
|---|
| 63 | import * as childProcess from 'child_process';
|
|---|
| 64 | import npmRunPath = require('npm-run-path');
|
|---|
| 65 |
|
|---|
| 66 | console.log(process.env.PATH);
|
|---|
| 67 | //=> '/usr/local/bin'
|
|---|
| 68 |
|
|---|
| 69 | console.log(npmRunPath());
|
|---|
| 70 | //=> '/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'
|
|---|
| 71 |
|
|---|
| 72 | // `foo` is a locally installed binary
|
|---|
| 73 | childProcess.execFileSync('foo', {
|
|---|
| 74 | env: npmRunPath.env()
|
|---|
| 75 | });
|
|---|
| 76 | ```
|
|---|
| 77 | */
|
|---|
| 78 | (options?: npmRunPath.RunPathOptions): string;
|
|---|
| 79 |
|
|---|
| 80 | /**
|
|---|
| 81 | @returns The augmented [`process.env`](https://nodejs.org/api/process.html#process_process_env) object.
|
|---|
| 82 | */
|
|---|
| 83 | env(options?: npmRunPath.EnvOptions): npmRunPath.ProcessEnv;
|
|---|
| 84 |
|
|---|
| 85 | // TODO: Remove this for the next major release
|
|---|
| 86 | default: typeof npmRunPath;
|
|---|
| 87 | };
|
|---|
| 88 |
|
|---|
| 89 | export = npmRunPath;
|
|---|