Last active
August 29, 2015 14:16
-
-
Save harto/4453bf0a9babb7b4c7d2 to your computer and use it in GitHub Desktop.
$PATH manager for npm projects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm-activate() { | |
npm-deactivate | |
export __NPM_PROJECT_BINS=$(__npm-project-bins $1) | |
export PATH=$__NPM_PROJECT_BINS:$PATH | |
} | |
npm-deactivate() { | |
if [[ -n $__NPM_PROJECT_BINS ]]; then | |
export PATH=${PATH#$__NPM_PROJECT_BINS:} | |
fi | |
} | |
__npm-project-bins() { | |
local npm_project_dir=${1:-.} | |
(cd $npm_project_dir && npm bin) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment