Socket
Socket
Sign inDemoInstall

path-key

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    path-key

Get the PATH environment variable key cross-platform


Version published
Maintainers
1
Install size
4.97 kB
Created

Package description

What is path-key?

The path-key npm package is used to get the environment variable used by the operating system to define the path for executables. This can be useful for cross-platform compatibility, as different operating systems use different environment variables ('PATH' on Windows, 'Path' on macOS and Linux).

What are path-key's main functionalities?

Get the PATH environment variable key

This feature allows you to retrieve the correct environment variable key for the system's PATH, which can be used to ensure cross-platform compatibility when working with system paths.

"const pathKey = require('path-key');

const key = pathKey(); // 'PATH' on Windows, 'Path' on macOS/Linux
console.log(`The PATH key is: ${key}`);"

Get the PATH environment variable key with options

This feature allows you to specify options such as the environment and platform, giving you more control over how the PATH key is determined, which can be useful for testing or specific use cases.

"const pathKey = require('path-key');

const options = { env: process.env, platform: 'win32' };
const key = pathKey(options); // Forces 'Path' even on Windows
console.log(`The PATH key is: ${key}`);"

Other packages similar to path-key

Readme

Source

path-key

Get the PATH 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

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

Use a custom environment variables object.

platform

Type: string
Default: 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.

Keywords

FAQs

Last updated on 09 Apr 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc