made npmrun a function

This commit is contained in:
pika 2024-08-26 17:24:37 +02:00
parent 7684407e5c
commit 0ed6669a22

20
.zshrc
View file

@ -357,7 +357,25 @@ _coding_() {
# Check if npm is available, then create the alias # Check if npm is available, then create the alias
if command_exists npm; then if command_exists npm; then
alias npmrun="npm run dev -- --host=$(get_ip) --port=8001" npmrun(){
npmrun_help() {
echo "Usage: npmrun [environment] [optional:port]"
echo " environment: The npm environment you want to run (e.g. dev)"
echo " port: Port to use (default: 8000)"
return
}
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
npmrun_help
return
fi
local env="$1"
local port="${2:-8080}"
npm run "$env" -- --host="$(get_ip)" --port="$port"
}
# alias npmrun='npm run "$1" -- --host=$(get_ip) --port=8001'
fi fi
} }