From 02e450f354ccd978c90425929c635139210843a3 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 2 Apr 2019 14:43:02 +0800 Subject: Add cargo-watch.check-arguments --- editors/code/src/utils/processes.ts | 68 ++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 32 deletions(-) (limited to 'editors/code/src/utils/processes.ts') diff --git a/editors/code/src/utils/processes.ts b/editors/code/src/utils/processes.ts index 09fdf6e24..d4c2c8778 100644 --- a/editors/code/src/utils/processes.ts +++ b/editors/code/src/utils/processes.ts @@ -5,36 +5,40 @@ import ChildProcess = cp.ChildProcess; import { join } from 'path'; -const isWindows = (process.platform === 'win32'); -const isMacintosh = (process.platform === 'darwin'); -const isLinux = (process.platform === 'linux'); +const isWindows = process.platform === 'win32'; +const isMacintosh = process.platform === 'darwin'; +const isLinux = process.platform === 'linux'; export function terminate(process: ChildProcess, cwd?: string): boolean { - if (isWindows) { - try { - // This we run in Atom execFileSync is available. - // Ignore stderr since this is otherwise piped to parent.stderr - // which might be already closed. - const options: any = { - stdio: ['pipe', 'pipe', 'ignore'] - }; - if (cwd) { - options.cwd = cwd - } - (cp).execFileSync('taskkill', ['/T', '/F', '/PID', process.pid.toString()], options); - return true; - } catch (err) { - return false; - } - } else if (isLinux || isMacintosh) { - try { - const cmd = join(__dirname, 'terminateProcess.sh'); - const result = cp.spawnSync(cmd, [process.pid.toString()]); - return result.error ? false : true; - } catch (err) { - return false; - } - } else { - process.kill('SIGKILL'); - return true; - } -} \ No newline at end of file + if (isWindows) { + try { + // This we run in Atom execFileSync is available. + // Ignore stderr since this is otherwise piped to parent.stderr + // which might be already closed. + const options: any = { + stdio: ['pipe', 'pipe', 'ignore'] + }; + if (cwd) { + options.cwd = cwd; + } + cp.execFileSync( + 'taskkill', + ['/T', '/F', '/PID', process.pid.toString()], + options + ); + return true; + } catch (err) { + return false; + } + } else if (isLinux || isMacintosh) { + try { + const cmd = join(__dirname, 'terminateProcess.sh'); + const result = cp.spawnSync(cmd, [process.pid.toString()]); + return result.error ? false : true; + } catch (err) { + return false; + } + } else { + process.kill('SIGKILL'); + return true; + } +} -- cgit v1.2.3