You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
967 B

4 years ago
  1. # path-key [![Build Status](https://travis-ci.org/sindresorhus/path-key.svg?branch=master)](https://travis-ci.org/sindresorhus/path-key)
  2. > Get the [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable key cross-platform
  3. It's usually `PATH`, but on Windows it can be any casing like `Path`...
  4. ## Install
  5. ```
  6. $ npm install --save path-key
  7. ```
  8. ## Usage
  9. ```js
  10. const pathKey = require('path-key');
  11. const key = pathKey();
  12. //=> 'PATH'
  13. const PATH = process.env[key];
  14. //=> '/usr/local/bin:/usr/bin:/bin'
  15. ```
  16. ## API
  17. ### pathKey([options])
  18. #### options
  19. ##### env
  20. Type: `Object`<br>
  21. Default: [`process.env`](https://nodejs.org/api/process.html#process_process_env)
  22. Use a custom environment variables object.
  23. #### platform
  24. Type: `string`<br>
  25. Default: [`process.platform`](https://nodejs.org/api/process.html#process_process_platform)
  26. Get the PATH key for a specific platform.
  27. ## License
  28. MIT © [Sindre Sorhus](https://sindresorhus.com)