mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
1f2370c2a9
Summary: build-client, aka packaging, aka bundling is now separate from uploading. This is both to compartmentalize our tasks a bit more and so we can add a non-grunt windows task inbetween packaging and uploading. No more heavily-overloaded PUBLISH_BUILD flag. Added SIGN_BUILD flag instead. No more TRAVIS and TRAVIS_PULL_REQUEST flag. Test Plan: Manual Reviewers: halla, juan, spang Reviewed By: juan, spang Differential Revision: https://phab.nylas.com/D4208
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
const childProcess = require('child_process');
|
|
|
|
module.exports = (grunt) => {
|
|
function spawn(options, callback) {
|
|
const stdout = [];
|
|
const stderr = [];
|
|
let error = null;
|
|
const proc = childProcess.spawn(options.cmd, options.args, options.opts);
|
|
proc.stdout.on('data', data => stdout.push(data.toString()));
|
|
proc.stderr.on('data', data => stderr.push(data.toString()));
|
|
proc.on('error', (processError) => {
|
|
return error != null ? error : (error = processError)
|
|
});
|
|
proc.on('close', (exitCode, signal) => {
|
|
if (exitCode !== 0) { if (typeof error === 'undefined' || error === null) { error = new Error(signal); } }
|
|
const results = {stderr: stderr.join(''), stdout: stdout.join(''), code: exitCode};
|
|
if (exitCode !== 0) { grunt.log.error(results.stderr); }
|
|
return callback(error, results, exitCode);
|
|
});
|
|
}
|
|
|
|
function spawnP(options) {
|
|
return new Promise((resolve, reject) => {
|
|
spawn(options, (error) => {
|
|
if (error) return reject(error);
|
|
return resolve()
|
|
})
|
|
})
|
|
}
|
|
|
|
return {spawn, spawnP};
|
|
}
|