add webi to npm as @root/webi@v0.5.0
[webi-installers/.git] / _npm / lib / exec.js
diff --git a/_npm/lib/exec.js b/_npm/lib/exec.js
new file mode 100644 (file)
index 0000000..7b70ce4
--- /dev/null
@@ -0,0 +1,30 @@
+'use strict';
+
+var pkg = require('../package.json');
+var spawn = require('child_process').spawn;
+var os = require('os');
+var path = require('path');
+
+function spawner(args) {
+  return new Promise(function (resolve, reject) {
+    var bin = args.shift();
+    var runner = spawn(bin, args, {
+      windowsHide: true
+    });
+    runner.stdout.on('data', function (chunk) {
+      console.info(chunk.toString('utf8'));
+    });
+    runner.stderr.on('data', function (chunk) {
+      console.error(chunk.toString('utf8'));
+    });
+    runner.on('exit', function (code) {
+      if (0 !== code) {
+        reject(new Error("exited with non-zero status code '" + code + "'"));
+        return;
+      }
+      resolve({ code: code });
+    });
+  });
+}
+
+module.exports = spawner;