Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

luizwbr
Copy link

@luizwbr luizwbr commented Mar 13, 2019

Added '*' character to filter program's name, removing mandatory program extension.

Fixes #1

@MarkTiedemann
Copy link

This will kill potentially unrelated programs, e.g. fkill note would also kill notepad.

@luizwbr
Copy link
Author

luizwbr commented Mar 13, 2019

Yes, you are right. I will made some changes.

@sindresorhus
Copy link
Owner

Bump

@luizwbr
Copy link
Author

luizwbr commented Jun 3, 2019

Done!

@@ -20,13 +20,25 @@ const missingBinaryError = async (command, arguments_) => {
}
};

const windowsKill = (input, options) => {
const killWithTask = (input, options) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Copy link
Owner

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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return killWithTask(secondTry, options);
return killWithTask(input.concat('.exe'), options);

const firstTry = input;
return await killWithTask(firstTry, options);
} catch (error) {
if (typeof input === 'string') {
Copy link
Owner

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 => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test.serial('win default without extension', async t => {
test.serial('window - supports extension-less process name', async t => {

@sindresorhus
Copy link
Owner

Support for this should be documented in readme and https://github.com/sindresorhus/fkill/blob/master/index.d.ts

@sindresorhus
Copy link
Owner

@luizwbr Still interested in finishing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make extension optional on Windows?
3 participants