Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cherryramatisdev/96b759a186215d61353b66d49d9fa9ea to your computer and use it in GitHub Desktop.
Save cherryramatisdev/96b759a186215d61353b66d49d9fa9ea to your computer and use it in GitHub Desktop.
#!/bin/sh
pushd "$(git rev-parse --show-toplevel)" &>/dev/null
get_package_manager() {
if [[ -f "yarn.lock" ]]; then
echo "yarn"
elif [[ -f "package-lock.json" ]]; then
echo "npm"
elif [[ -f "pnpm-lock.yaml" ]]; then
echo "pnpm"
else
echo "none"
fi
}
package_manager=$(get_package_manager)
popd &>/dev/null
if [[ "$package_manager" == "none" ]]; then
echo "Could not determine package manager"
exit 1
fi
"$package_manager" "$@"
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment