pax_global_header00006660000000000000000000000064140340413210014502gustar00rootroot0000000000000052 comment=d5ad08865acad539d2d64655f14987a7ad764451 path-key-4.0.0/000077500000000000000000000000001403404132100132255ustar00rootroot00000000000000path-key-4.0.0/.editorconfig000066400000000000000000000002571403404132100157060ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 path-key-4.0.0/.gitattributes000066400000000000000000000000231403404132100161130ustar00rootroot00000000000000* text=auto eol=lf path-key-4.0.0/.github/000077500000000000000000000000001403404132100145655ustar00rootroot00000000000000path-key-4.0.0/.github/funding.yml000066400000000000000000000001621403404132100167410ustar00rootroot00000000000000github: sindresorhus open_collective: sindresorhus tidelift: npm/path-key custom: https://sindresorhus.com/donate path-key-4.0.0/.github/security.md000066400000000000000000000002631403404132100167570ustar00rootroot00000000000000# Security Policy To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. path-key-4.0.0/.github/workflows/000077500000000000000000000000001403404132100166225ustar00rootroot00000000000000path-key-4.0.0/.github/workflows/main.yml000066400000000000000000000006451403404132100202760ustar00rootroot00000000000000name: CI on: - push - pull_request jobs: test: name: Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: node-version: - 14 - 12 steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test path-key-4.0.0/.gitignore000066400000000000000000000000271403404132100152140ustar00rootroot00000000000000node_modules yarn.lock path-key-4.0.0/.npmrc000066400000000000000000000000231403404132100143400ustar00rootroot00000000000000package-lock=false path-key-4.0.0/index.d.ts000066400000000000000000000013321403404132100151250ustar00rootroot00000000000000export interface Options { /** Use a custom environment variables object. Default: [`process.env`](https://nodejs.org/api/process.html#process_process_env). */ readonly env?: Record; /** Get the PATH key for a specific platform. Default: [`process.platform`](https://nodejs.org/api/process.html#process_process_platform). */ readonly platform?: NodeJS.Platform; } /** Get the [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable key cross-platform. @example ``` import pathKey from 'path-key'; const key = pathKey(); //=> 'PATH' const PATH = process.env[key]; //=> '/usr/local/bin:/usr/bin:/bin' ``` */ export default function pathKey(options?: Options): string; path-key-4.0.0/index.js000066400000000000000000000004071403404132100146730ustar00rootroot00000000000000export default function pathKey(options = {}) { const { env = process.env, platform = process.platform } = options; if (platform !== 'win32') { return 'PATH'; } return Object.keys(env).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path'; } path-key-4.0.0/index.test-d.ts000066400000000000000000000002741403404132100161060ustar00rootroot00000000000000import {expectType} from 'tsd'; import pathKey from './index.js'; expectType(pathKey()); expectType(pathKey({env: {}})); expectType(pathKey({platform: 'win32'})); path-key-4.0.0/license000066400000000000000000000021351403404132100145730ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. path-key-4.0.0/package.json000066400000000000000000000013621403404132100155150ustar00rootroot00000000000000{ "name": "path-key", "version": "4.0.0", "description": "Get the PATH environment variable key cross-platform", "license": "MIT", "repository": "sindresorhus/path-key", "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, "type": "module", "exports": "./index.js", "engines": { "node": ">=12" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "path", "key", "environment", "env", "variable", "get", "cross-platform", "windows" ], "devDependencies": { "@types/node": "^14.14.37", "ava": "^3.15.0", "tsd": "^0.14.0", "xo": "^0.38.2" } } path-key-4.0.0/readme.md000066400000000000000000000022651403404132100150110ustar00rootroot00000000000000# path-key > Get the [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable key cross-platform It's usually `PATH` but on Windows it can be any casing like `Path`... ## Install ``` $ npm install path-key ``` ## Usage ```js import pathKey from 'path-key'; const key = pathKey(); //=> 'PATH' const PATH = process.env[key]; //=> '/usr/local/bin:/usr/bin:/bin' ``` ## API ### pathKey(options?) #### options Type: `object` ##### env Type: `object`\ Default: [`process.env`](https://nodejs.org/api/process.html#process_process_env) Use a custom environment variables object. #### platform Type: `string`\ Default: [`process.platform`](https://nodejs.org/api/process.html#process_process_platform) Get the PATH key for a specific platform. ---
Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.
path-key-4.0.0/test.js000066400000000000000000000007411403404132100145440ustar00rootroot00000000000000import test from 'ava'; import pathKey from './index.js'; test('main', t => { t.is(pathKey().toUpperCase(), 'PATH'); t.is(pathKey({env: {PATH: ''}}), 'PATH'); t.is(pathKey({env: {Path: ''}, platform: 'win32'}), 'Path'); t.is(pathKey({env: {}, platform: 'darwin'}), 'PATH'); t.is(pathKey({env: {}, platform: 'win32'}), 'Path'); t.is(pathKey({env: {Path: '', PATH: ''}, platform: 'win32'}), 'PATH'); t.is(pathKey({env: {PATH: '', Path: ''}, platform: 'win32'}), 'Path'); });