Skip to content

Instantly share code, notes, and snippets.

@dan-dr
Last active July 26, 2021 22:44
Show Gist options
  • Save dan-dr/9593a60cf9d5b7242b0cf0d97d64baf5 to your computer and use it in GitHub Desktop.
Save dan-dr/9593a60cf9d5b7242b0cf0d97d64baf5 to your computer and use it in GitHub Desktop.
Kill webpack-dev-server with babun on windows
# usage: killwebpack [port]
# if no port is supplied then default port is 3000
function killwebpack() {
PORT=3000
if [ -n "$1" ]
then
PORT=$1
fi
PID=`netstat -aon | grep $PORT | grep -P -m1 '(?<=LISTENING).*' -o | grep -P '\d*' -o`
if [ -z "$PID" ]
then
echo "couldn't find a process with port $PORT"
else
echo "killing process $PID with port $PORT"
taskkill /pid $PID /f
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment