refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / _npm / lib / exec.js
1 'use strict';
2
3 var pkg = require('../package.json');
4 var spawn = require('child_process').spawn;
5 var os = require('os');
6 var path = require('path');
7
8 function spawner(args) {
9   return new Promise(function (resolve, reject) {
10     var bin = args.shift();
11     var runner = spawn(bin, args, {
12       windowsHide: true
13     });
14     runner.stdout.on('data', function (chunk) {
15       console.info(chunk.toString('utf8'));
16     });
17     runner.stderr.on('data', function (chunk) {
18       console.error(chunk.toString('utf8'));
19     });
20     runner.on('exit', function (code) {
21       if (0 !== code) {
22         reject(new Error("exited with non-zero status code '" + code + "'"));
23         return;
24       }
25       resolve({ code: code });
26     });
27   });
28 }
29
30 module.exports = spawner;