Skip to content

Commit

Permalink
fix: enhance error handling in findAndKillProcess
Browse files Browse the repository at this point in the history
  • Loading branch information
luckfunc committed Oct 19, 2024
1 parent 3d47928 commit b9f43d9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# kill-port-process-cli
# kill-port-process-cli ![npm downloads](https://img.shields.io/npm/dt/kill-port-process-cli)

A CLI tool to kill processes by port. This tool allows you to terminate processes running on specified ports. It is useful for developers who need to quickly free up ports during development.

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const findAndKillProcess = (port) => {
}

const pid = process.platform === 'win32'
? stdout.split('\n').find(line => line.includes('LISTEN')).trim().split(/\s+/).pop()
? stdout.split('\n').find(line => line.includes('LISTEN'))?.trim().split(/\s+/).pop()
: stdout.split('\n').map(line => line.trim()).filter(line => line).pop();

if (pid) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kill-port-process-cli",
"version": "1.0.8",
"version": "1.0.9",
"description": "A CLI tool to kill processes by port",
"main": "index.js",
"bin": {
Expand Down

0 comments on commit b9f43d9

Please sign in to comment.