Add npm and yarn checks

master
Hektor Misplon 2024-12-14 16:33:37 +01:00
parent d9603c543c
commit a758946e82
1 changed files with 31 additions and 0 deletions

View File

@ -11,6 +11,7 @@ alias eal="nvim ~/.bash_aliasrc"
alias ev="edit_editor_config"
# Navigation
alias ..="cd .."
alias .2="cd ../.."
alias .3="cd ../../.."
@ -72,3 +73,33 @@ alias r="R"
alias azerty="setxkbmap be"
alias qwerty="setxkbmap us"
alias cole="setxkbmap us -variant colemak"
yarn() {
if [[ -f "package-lock.json" ]]; then
echo "WARNING: package-lock.json exists"
read -p "Are you sure you want to run yarn? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
command yarn "$@"
else
echo "Aborted"
fi
else
command yarn "$@"
fi
}
npm() {
if [[ -f "yarn.lock" ]]; then
echo "WARNING: yarn.lock exists"
read -p "Are you sure you want to run npm? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
command npm "$@"
else
echo "Aborted"
fi
else
command npm "$@"
fi
}