Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
manage-path
Advanced tools
The manage-path npm package allows you to easily manipulate the PATH environment variable in Node.js. This can be useful for adding or removing directories from the PATH, ensuring that your scripts and applications can find the executables they need.
Add a directory to the PATH
This feature allows you to add a directory to the beginning of the PATH environment variable. This can be useful if you want to ensure that a specific directory is searched first when looking for executables.
const managePath = require('manage-path');
const path = managePath(process.env);
path.unshift('/usr/local/bin');
Remove a directory from the PATH
This feature allows you to remove a directory from the PATH environment variable. This can be useful if you want to ensure that a specific directory is not searched when looking for executables.
const managePath = require('manage-path');
const path = managePath(process.env);
path.remove('/usr/local/bin');
Add a directory to the end of the PATH
This feature allows you to add a directory to the end of the PATH environment variable. This can be useful if you want to ensure that a specific directory is searched last when looking for executables.
const managePath = require('manage-path');
const path = managePath(process.env);
path.push('/usr/local/bin');
The 'path' package provides utilities for working with file and directory paths. While it does not directly manipulate the PATH environment variable, it offers a wide range of methods for handling and transforming file paths, which can be useful in conjunction with manage-path.
The 'env-paths' package provides the directory paths for storing various types of data (e.g., config, cache, data) for your application. It does not manipulate the PATH environment variable but helps in managing environment-specific paths for application data.
The 'cross-env' package allows you to set environment variables across different platforms. While it does not specifically manage the PATH variable, it is useful for setting environment variables in a cross-platform way, which can be used in conjunction with manage-path.
This micro-lib allows you to alter the $PATH
in a cross-platform way.
var path = require('path')
var managePath = require('manage-path')
var alterPath = managePath(process.env)
alterPath.shift(path.join(process.cwd(), 'node_modules', '.bin') // add one path to the beginning
// process.env.PATH now starts with the `.bin` in your `node_modules` directory :-)
// unless you happen to be running on windows, in which case it *might* be process.env.Path :-)
// but you don't have to think about that...
alterPath.push('~/custombin', '/usr/other/bin') // add multiple paths to the end
alterPath.push(['~/foo/bar', '/bar/foo/bin']) // array-style multi-path add for ultimate flexibility :-)
// need to get the path value cross-platform?
alterPath.get() // <-- returns value of PATH or Path... depending :-)
// want to restore the path to what it was before you mucked with it?
// just call the function you get back:
alterPath.restore()
These are options you pass as an object to managePath
Allows you to specify your own platform. Defaults to process.platform
. Currently the only meaningful value is
'win32'
. This option is mainly available for testing purposes.
LICENSE -> MIT
Much of the original code for this came from npm/npm
FAQs
Cross-platform method to add a directory to your $PATH
The npm package manage-path receives a total of 140,047 weekly downloads. As such, manage-path popularity was classified as popular.
We found that manage-path demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.