No Description

index.d.ts 2.3KB

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