From 0ed6669a22d218dde7b56724d299587eb066ea7e Mon Sep 17 00:00:00 2001 From: pika Date: Mon, 26 Aug 2024 17:24:37 +0200 Subject: [PATCH] made npmrun a function --- .zshrc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.zshrc b/.zshrc index 5957786..30099d3 100644 --- a/.zshrc +++ b/.zshrc @@ -357,7 +357,25 @@ _coding_() { # Check if npm is available, then create the alias 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 }