Finish Windows compatibility for shutdown process

This commit is contained in:
Alex Liebowitz 2017-03-26 07:02:28 -04:00 committed by Alex Grintsvayg
parent f409c5f3ec
commit 70da416ca2

View file

@ -40,7 +40,7 @@ function openItem(fullPath) {
} else if (process.platform == 'linux') { } else if (process.platform == 'linux') {
child = child_process.spawn('xdg-open', [fullPath], subprocOptions); child = child_process.spawn('xdg-open', [fullPath], subprocOptions);
} else if (process.platform == 'win32') { } else if (process.platform == 'win32') {
child = child_process.execSync('start', [fullPath], subprocOptions); child = child_process.spawn(fullPath, [], subprocOptions);
} }
// Causes child process reference to be garbage collected, allowing main process to exit // Causes child process reference to be garbage collected, allowing main process to exit
@ -48,12 +48,13 @@ function openItem(fullPath) {
} }
function getPidsForProcessName(name) { function getPidsForProcessName(name) {
if (process.platform == 'windows') { if (process.platform == 'win32') {
const tasklistOut = child_process.execSync('tasklist', const tasklistOut = child_process.execSync(`tasklist /fi "Imagename eq ${name}.exe" /nh`, {encoding: 'utf8'});
['/fi', `Imagename eq ${name}.exe`, '/nh'], if (tasklistOut.startsWith('INFO')) {
{encoding: 'utf8'} return [];
).stdout; } else {
return tasklistOut.match(/[^\n]+/g).map((line) => line.split(/\s+/)[1]); // Second column of every non-empty line return tasklistOut.match(/[^\r\n]+/g).map((line) => line.split(/\s+/)[1]); // Second column of every non-empty line
}
} else { } else {
const pgrepOut = child_process.spawnSync('pgrep', ['-x', name], {encoding: 'utf8'}).stdout; const pgrepOut = child_process.spawnSync('pgrep', ['-x', name], {encoding: 'utf8'}).stdout;
return pgrepOut.match(/\d+/g); return pgrepOut.match(/\d+/g);