Last active
September 26, 2024 23:42
-
-
Save zakmandhro/828e857ae6180a00beb4750984bb8871 to your computer and use it in GitHub Desktop.
Run appropriate package manager (`yarn`, `npm`, or `pnpm`) with single `nn` command
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
# run the appropriate package manager | |
npm-etc() { | |
if [[ -f package-lock.json ]]; then | |
npm run "$@" | |
elif [[ -f yarn.lock ]]; then | |
yarn "$@" | |
elif [[ -f pnpm-lock.yaml ]]; then | |
pnpm "$@" | |
else | |
echo "Error: Could not detect package manager." | |
fi | |
} | |
alias nn="npm-etc" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instead of having to think about which package manager you use per project, append the above gist into your
~/.zshrc
and simply usenn
command everywhere.