Last active
June 5, 2024 10:36
-
-
Save lukemartin/5667328c9597f132724a607ec100197c to your computer and use it in GitHub Desktop.
Automatically use the correct package manager
This file contains 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
detect_and_run() { | |
if [ -f "bun.lockb" ]; then | |
bun "$@" | |
elif [ -f "pnpm-lock.yaml" ]; then | |
pnpm "$@" | |
elif [ -f "yarn.lock" ]; then | |
yarn "$@" | |
elif [ -f "package-lock.json" ]; then | |
npm "$@" | |
else | |
echo "No known package manager lockfile found in the current directory." | |
return 1 | |
fi | |
} | |
# Create an alias to use the function | |
alias n='detect_and_run' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment