Last active
September 15, 2025 12:32
-
-
Save rorhug/4682e3ce775f9dfe7a9c8867886c2a57 to your computer and use it in GitHub Desktop.
Use the right js package manager
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
| p() { | |
| if [[ -f bun.lockb ]]; then | |
| echo "Using bun" | |
| command bun "$@" | |
| elif [[ -f pnpm-lock.yaml ]]; then | |
| echo "Using pnpm" | |
| command pnpm "$@" | |
| elif [[ -f yarn.lock ]]; then | |
| echo "Using yarn" | |
| command yarn "$@" | |
| elif [[ -f package-lock.json ]]; then | |
| echo "Using npm" | |
| command npm "$@" | |
| elif [[ -f deno.json ]]; then # untested | |
| echo "Using deno" | |
| command deno "$@" | |
| else | |
| if [[ "${ZSH_ALIAS_EXPANSION:-}" == "npm" ]]; then | |
| echo "No js package manager detected, using npm" | |
| command npm "$@" | |
| else | |
| echo "No js package manager detected" | |
| fi | |
| fi | |
| } | |
| alias npm='ZSH_ALIAS_EXPANSION=npm p' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment