From 5bf3819c23552aa303761ab454a7c857aece50fc Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Mon, 4 Feb 2019 12:59:10 +0100 Subject: [PATCH] powershell catch error --- lib/util.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/util.js b/lib/util.js index 8558c75..8eb7f14 100644 --- a/lib/util.js +++ b/lib/util.js @@ -237,9 +237,17 @@ function powerShell(cmd) { child.kill(); resolve(result); }); + child.on('error', function () { + child.kill(); + resolve(result); + }); - child.stdin.write(cmd + '\n'); - child.stdin.end(); + try { + child.stdin.write(cmd + '\n'); + child.stdin.end(); + } catch (e) { + reject(result) + } } else { reject(result); }