Files
vim-ale/_npm/lib/exec.js
2023-10-12 00:08:27 +00:00

28 lines
673 B
JavaScript

'use strict';
var spawn = require('child_process').spawn;
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;