Created
March 31, 2026 18:32
-
-
Save amsryq/020c1b36514f0d7b872056d2748e8a2a to your computer and use it in GitHub Desktop.
Map `npm` to `pnpm` for global installation
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() { | |
| local cmd="$1" | |
| shift | |
| if [[ " $* " == *" -g "* || " $* " == *" --global "* ]]; then | |
| case "$cmd" in | |
| install|i) command pnpm add -g "${@/-g/}" "${@/--global/}"; return ;; | |
| update|up|upgrade) command pnpm update -g "${@/-g/}" "${@/--global/}"; return ;; | |
| uninstall|remove|rm) command pnpm remove -g "${@/-g/}" "${@/--global/}"; return ;; | |
| esac | |
| fi | |
| command npm "$cmd" "$@" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment