manage-path
Cross-platform method to add a directory to your $PATH
Last updated 10 years ago by kentcdodds .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install manage-path 
SYNC missed versions from official npm registry.

manage-path

Status: npm version npm downloads Build Status Code Coverage

This micro-lib allows you to alter the $PATH in a cross-platform way.

Main Usage

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()

options

These are options you pass as an object to managePath

platform

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.

Other info

LICENSE -> MIT

Much of the original code for this came from npm/npm

Current Tags

  • 2.0.0                                ...           latest (10 years ago)

3 Versions

  • 2.0.0                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (15)
Dependents (3)

Copyright 2013 - present © cnpmjs.org | Home |