Last change
on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
967 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | # path-key [![Build Status](https://travis-ci.org/sindresorhus/path-key.svg?branch=master)](https://travis-ci.org/sindresorhus/path-key)
|
---|
| 2 |
|
---|
| 3 | > Get the [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable key cross-platform
|
---|
| 4 |
|
---|
| 5 | It's usually `PATH`, but on Windows it can be any casing like `Path`...
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | ## Install
|
---|
| 9 |
|
---|
| 10 | ```
|
---|
| 11 | $ npm install --save path-key
|
---|
| 12 | ```
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | ## Usage
|
---|
| 16 |
|
---|
| 17 | ```js
|
---|
| 18 | const pathKey = require('path-key');
|
---|
| 19 |
|
---|
| 20 | const key = pathKey();
|
---|
| 21 | //=> 'PATH'
|
---|
| 22 |
|
---|
| 23 | const PATH = process.env[key];
|
---|
| 24 | //=> '/usr/local/bin:/usr/bin:/bin'
|
---|
| 25 | ```
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | ## API
|
---|
| 29 |
|
---|
| 30 | ### pathKey([options])
|
---|
| 31 |
|
---|
| 32 | #### options
|
---|
| 33 |
|
---|
| 34 | ##### env
|
---|
| 35 |
|
---|
| 36 | Type: `Object`<br>
|
---|
| 37 | Default: [`process.env`](https://nodejs.org/api/process.html#process_process_env)
|
---|
| 38 |
|
---|
| 39 | Use a custom environment variables object.
|
---|
| 40 |
|
---|
| 41 | #### platform
|
---|
| 42 |
|
---|
| 43 | Type: `string`<br>
|
---|
| 44 | Default: [`process.platform`](https://nodejs.org/api/process.html#process_process_platform)
|
---|
| 45 |
|
---|
| 46 | Get the PATH key for a specific platform.
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | ## License
|
---|
| 50 |
|
---|
| 51 | MIT © [Sindre Sorhus](https://sindresorhus.com)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.