Comparing version 5.1.0 to 5.2.0
38
index.js
@@ -7,3 +7,3 @@ 'use strict'; | ||
function win(input, opts) { | ||
function winKill(input, opts) { | ||
return taskkill(input, { | ||
@@ -15,4 +15,5 @@ force: opts.force, | ||
function def(input, opts) { | ||
const cmd = typeof input === 'string' ? 'killall' : 'kill'; | ||
function macOSKill(input, opts) { | ||
const killByName = typeof input === 'string'; | ||
const cmd = killByName ? 'pkill' : 'kill'; | ||
const args = [input]; | ||
@@ -24,11 +25,38 @@ | ||
if (killByName && opts.ignoreCase) { | ||
args.unshift('-i'); | ||
} | ||
return execa(cmd, args); | ||
} | ||
function defaultKill(input, opts) { | ||
const killByName = typeof input === 'string'; | ||
const cmd = killByName ? 'killall' : 'kill'; | ||
const args = [input]; | ||
if (opts.force) { | ||
args.unshift('-9'); | ||
} | ||
if (killByName && opts.ignoreCase) { | ||
args.unshift('-I'); | ||
} | ||
return execa(cmd, args); | ||
} | ||
module.exports = (input, opts) => { | ||
opts = opts || {}; | ||
const fn = process.platform === 'win32' ? win : def; | ||
const errors = []; | ||
let fn; | ||
if (process.platform === 'darwin') { | ||
fn = macOSKill; | ||
} else if (process.platform === 'win32') { | ||
fn = winKill; | ||
} else { | ||
fn = defaultKill; | ||
} | ||
// Don't kill ourselves | ||
@@ -35,0 +63,0 @@ input = arrify(input).filter(x => x !== process.pid); |
{ | ||
"name": "fkill", | ||
"version": "5.1.0", | ||
"version": "5.2.0", | ||
"description": "Fabulously kill processes. Cross-platform.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -46,3 +46,3 @@ <h1 align="center"> | ||
Type: `number` `string` `Array<number|string>` | ||
Type: `number` `string` `number[]` `string[]` | ||
@@ -67,3 +67,12 @@ One or more process IDs/names to kill. | ||
##### ignoreCase | ||
Type: `boolean`<br> | ||
Default: `false` | ||
Ignore capitalization when killing a process. | ||
Note that the case is always ignored on Windows. | ||
## Related | ||
@@ -70,0 +79,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4930
58
85