prepend-path
Prepend a path to the existing PATH
environment variable cross-platform way
const prependPath = ; processenvPATH; //=> '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' ; processenvPATH; //=> 'additional/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'
Installation
npm install prepend-path
API
const prependPath = ;
prependPath(path)
path: string
(a path to prepend)
Return: string
(modified PATH
environment variable)
It prepends the given path to the process.env.PATH
, or its equivalent on Windows for example process.env.Path
, along with the platform-specific path delimiter.
;// POSIX//=> 'foo/bar:/usr/local/bin:/usr/bin:/bin:...' // Windows//=> 'foo\\bar;C:\\Users\\appveyor\\AppData\\Roaming\\npm;C:\\...'
Prepending a new path to the PATH
is, in other words, making it precedent to the every existing one while searching executable files.
const existsSync = ;const which = ; ; //=> true which; //=> '/usr/local/bin/npm';which; //=> '/User/example/new_path/npm/bin/npm'
License
ISC License © 2017 Shinnosuke Watanabe