-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make extension optional in Windows #32
Conversation
This will kill potentially unrelated programs, e.g. |
Yes, you are right. I will made some changes. |
Bump |
Fixed kill program with or without .exe
Done! |
@@ -20,13 +20,25 @@ const missingBinaryError = async (command, arguments_) => { | |||
} | |||
}; | |||
|
|||
const windowsKill = (input, options) => { | |||
const killWithTask = (input, options) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const killWithTask = (input, options) => { | |
const killWithTaskkill = (input, options) => { |
return taskkill(input, { | ||
force: options.force, | ||
tree: typeof options.tree === 'undefined' ? true : options.tree | ||
}); | ||
}; | ||
|
||
const windowsKill = async (input, options) => { | ||
try { | ||
const firstTry = input; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There variables are not useful.
const windowsKill = async (input, options) => { | ||
try { | ||
const firstTry = input; | ||
return await killWithTask(firstTry, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return await killWithTask(firstTry, options); | |
return await killWithTask(input, options); |
} catch (error) { | ||
if (typeof input === 'string') { | ||
const secondTry = input.concat('.exe'); | ||
return killWithTask(secondTry, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return killWithTask(secondTry, options); | |
return killWithTask(input.concat('.exe'), options); |
const firstTry = input; | ||
return await killWithTask(firstTry, options); | ||
} catch (error) { | ||
if (typeof input === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are swallowing the error if it's not a string. When fixing this, also add a regression test.
@@ -29,6 +29,15 @@ if (process.platform === 'win32') { | |||
t.false(await processExists(pid)); | |||
}); | |||
|
|||
test.serial('win default without extension', async t => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test.serial('win default without extension', async t => { | |
test.serial('window - supports extension-less process name', async t => { |
Support for this should be documented in readme and https://github.com/sindresorhus/fkill/blob/master/index.d.ts |
@luizwbr Still interested in finishing this? |
Added '*' character to filter program's name, removing mandatory program extension.
Fixes #1