appstore and support: async'ify

This commit is contained in:
Girish Ramakrishnan
2021-08-18 15:54:53 -07:00
parent 200018a022
commit 03e22170da
16 changed files with 458 additions and 633 deletions

View File

@@ -53,6 +53,7 @@ function spawn(tag, file, args, options, callback) {
debug(tag + ' spawn: %s %s', file, args.join(' ').replace(/\n/g, '\\n'));
const cp = child_process.spawn(file, args, options);
let stdoutResult = '';
if (options.logStream) {
cp.stdout.pipe(options.logStream);
@@ -60,6 +61,7 @@ function spawn(tag, file, args, options, callback) {
} else {
cp.stdout.on('data', function (data) {
debug(tag + ' (stdout): %s', data.toString('utf8'));
stdoutResult += data.toString('utf8');
});
cp.stderr.on('data', function (data) {
@@ -69,7 +71,7 @@ function spawn(tag, file, args, options, callback) {
cp.on('exit', function (code, signal) {
if (code || signal) debug(tag + ' code: %s, signal: %s', code, signal);
if (code === 0) return callback(null);
if (code === 0) return callback(null, stdoutResult);
let e = new BoxError(BoxError.SPAWN_ERROR, `${tag} exited with code ${code} signal ${signal}`);
e.code = code;