From 42ec01bb91c517067a9eba901272c1248ed52261 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 31 May 2017 14:42:22 -0300 Subject: Modularize it all --- src/promisify-process.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/promisify-process.js (limited to 'src/promisify-process.js') diff --git a/src/promisify-process.js b/src/promisify-process.js new file mode 100644 index 0000000..877cb8d --- /dev/null +++ b/src/promisify-process.js @@ -0,0 +1,19 @@ +'use strict' + +module.exports = function promisifyProcess(proc, showLogging = true) { + return new Promise((resolve, reject) => { + if (showLogging) { + proc.stdout.pipe(process.stdout) + proc.stderr.pipe(process.stderr) + } + + proc.on('exit', code => { + if (code === 0) { + resolve() + } else { + console.error('Process failed!', proc.spawnargs) + reject(code) + } + }) + }) +} -- cgit 1.3.0-6-gf8a5