index.d.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /// <reference types="node" />
  2. declare namespace pathKey {
  3. interface Options {
  4. /**
  5. Use a custom environment variables object. Default: [`process.env`](https://nodejs.org/api/process.html#process_process_env).
  6. */
  7. readonly env?: {[key: string]: string | undefined};
  8. /**
  9. Get the PATH key for a specific platform. Default: [`process.platform`](https://nodejs.org/api/process.html#process_process_platform).
  10. */
  11. readonly platform?: NodeJS.Platform;
  12. }
  13. }
  14. declare const pathKey: {
  15. /**
  16. Get the [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable key cross-platform.
  17. @example
  18. ```
  19. import pathKey = require('path-key');
  20. const key = pathKey();
  21. //=> 'PATH'
  22. const PATH = process.env[key];
  23. //=> '/usr/local/bin:/usr/bin:/bin'
  24. ```
  25. */
  26. (options?: pathKey.Options): string;
  27. // TODO: Remove this for the next major release, refactor the whole definition to:
  28. // declare function pathKey(options?: pathKey.Options): string;
  29. // export = pathKey;
  30. default: typeof pathKey;
  31. };
  32. export = pathKey;