Comparing version 8.0.1 to 8.1.0
17
index.js
@@ -110,2 +110,14 @@ import process from 'node:process'; | ||
const getCurrentProcessParentsPID = processes => { | ||
const processMap = new Map(processes.map(ps => [ps.pid, ps.ppid])); | ||
const pids = []; | ||
let currentId = process.pid; | ||
while (currentId) { | ||
pids.push(currentId); | ||
currentId = processMap.get(currentId); | ||
} | ||
return pids; | ||
}; | ||
const killWithLimits = async (input, options) => { | ||
@@ -118,6 +130,7 @@ input = await parseInput(input); | ||
if (input === 'node') { | ||
if (input === 'node' || input === 'node.exe') { | ||
const processes = await psList(); | ||
const pids = getCurrentProcessParentsPID(processes); | ||
await Promise.all(processes.map(async ps => { | ||
if (ps.name === 'node' && ps.pid !== process.pid) { | ||
if ((ps.name === 'node' || ps.name === 'node.exe') && !pids.includes(ps.pid)) { | ||
await kill(ps.pid, options); | ||
@@ -124,0 +137,0 @@ } |
{ | ||
"name": "fkill", | ||
"version": "8.0.1", | ||
"version": "8.1.0", | ||
"description": "Fabulously kill processes. Cross-platform.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
10003
205