Skip to content

Instantly share code, notes, and snippets.

@trkaplan
Forked from danielbayley/pnpm.command
Created December 8, 2021 17:52
Show Gist options
  • Save trkaplan/84de03c05689dfff6e8a78c79aa28da9 to your computer and use it in GitHub Desktop.
Save trkaplan/84de03c05689dfff6e8a78c79aa28da9 to your computer and use it in GitHub Desktop.
A shim to seamlessly alias @npm to @pnpm.
#! /bin/zsh --no-rcs --err-exit
export PATH=node_modules/.bin:$PATH
alias -g i=install
if (($+commands[pnpm])) then
local p=p
alias pnpm=npm npx=pnpx
# FIXME https://github.com/pnpm/pnpm/issues/1360
npm config get -g global-dir | read
path+=$REPLY/bin
fi
npm () {
case $1 in
env) command npx --call env;;
*) command ${p}npm ${@/uninstall/remove}
esac
}
source <(npx --shell-auto-fallback --no-install zsh)
[ $ZSH_EVAL_CONTEXT = toplevel ] && $0:t:r $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment