Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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