Skip to content

Instantly share code, notes, and snippets.

@adeluccar
Forked from danielbayley/pnpm.command
Created August 9, 2017 07:32
Show Gist options
  • Save adeluccar/d7ffd5381efa9192f06ede6435ab065f to your computer and use it in GitHub Desktop.
Save adeluccar/d7ffd5381efa9192f06ede6435ab065f to your computer and use it in GitHub Desktop.
A binstub to seamlessly alias @npm to @pnpm.
#! /bin/zsh -f
disable which # builtin
alias -g i=install
pnpm () { command pnpm $@ --config ${NPM_CONFIG_USERCONFIG:-~/.npmrc} }
if (which -s pnpm) npm () {
NODE_BIN=`brew --prefix node`/bin
export PATH=$PATH:$NODE_BIN
case $@ in
-g*) npm $2 -g ${@[3,#]};;
install*)
pnpm $@ &
if (which -s npm-install-peers) npm-install-peers;;
(rm|un)*-g*)
pnpm $@
rm $NODE_BIN/$@[#];;
*) pnpm $@;;
esac
}
[ $ZSH_EVAL_CONTEXT = toplevel ] && npm $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment