Skip to content

Commit

Permalink
Fix getting available browser processes on Windows (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeGkas authored Apr 23, 2022
1 parent d6a500f commit c69d2ce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ const TEN_MEBIBYTE = 1024 * 1024 * 10;

export default async function killTabs() {
const command = 'wmic process where Caption=\'chrome.exe\' get CommandLine,ProcessId /format:list';
const stdout = await promisify(childProcess.exec)(command, {maxBuffer: TEN_MEBIBYTE});
const response = await promisify(childProcess.exec)(command, {maxBuffer: TEN_MEBIBYTE});

return execall(/CommandLine=(.+)\s+ProcessId=(\d+)/g, stdout).map(element => ({
if (response.stderr) {
throw new Error('Failed to kill tabs.', {cause: new Error(response.stderr)});
}

return execall(/CommandLine=(.+)\s+ProcessId=(\d+)/g, response.stdout).map(element => ({
cmd: element.subMatches[0],
pid: Number.parseInt(element.subMatches[1], 10),
}));
Expand Down

0 comments on commit c69d2ce

Please # to comment.