From a49abc7c67f59df009198f174d03cb829237fb87 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Fri, 19 May 2017 20:28:15 -0600 Subject: [PATCH] Catch spawn errors --- core/archive_util.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/core/archive_util.js b/core/archive_util.js index 62f81059..0d4ae05c 100644 --- a/core/archive_util.js +++ b/core/archive_util.js @@ -172,7 +172,13 @@ module.exports = class ArchiveUtil { }; const args = archiver.compress.args.map( arg => stringFormat(arg, fmtObj) ); - const proc = pty.spawn(archiver.compress.cmd, args, this.getPtyOpts()); + + let proc; + try { + proc = pty.spawn(archiver.compress.cmd, args, this.getPtyOpts()); + } catch(e) { + return cb(e); + } return this.spawnHandler(proc, 'Compression', cb); } @@ -212,7 +218,12 @@ module.exports = class ArchiveUtil { args.splice.apply(args, [fileListPos, 1].concat(fileList)); } - const proc = pty.spawn(archiver[action].cmd, args, this.getPtyOpts()); + let proc; + try { + proc = pty.spawn(archiver[action].cmd, args, this.getPtyOpts()); + } catch(e) { + return cb(e); + } return this.spawnHandler(proc, (haveFileList ? 'Extraction' : 'Decompression'), cb); } @@ -229,7 +240,13 @@ module.exports = class ArchiveUtil { }; const args = archiver.list.args.map( arg => stringFormat(arg, fmtObj) ); - const proc = pty.spawn(archiver.list.cmd, args, this.getPtyOpts()); + + let proc; + try { + proc = pty.spawn(archiver.list.cmd, args, this.getPtyOpts()); + } catch(e) { + return cb(e); + } let output = ''; proc.on('data', data => {