fix(packager): output rebuild errors if there are any

This commit is contained in:
Samuel Attard 2016-12-11 13:29:40 +11:00 коммит произвёл Mark Lee
Родитель ed9137dd13
Коммит f8ffca1398
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -43,7 +43,6 @@ export default async (buildPath, electronVersion, pPlatform, pArch) => {
await new Promise((resolve, reject) => {
const child = spawn(process.execPath, [path.resolve(__dirname, '../../node_modules/.bin/node-gyp')].concat(rebuildArgs), {
cwd: modulePath,
// stdio: 'inherit',
env: Object.assign({}, process.env, {
HOME: path.resolve(os.homedir(), '.electron-gyp'),
USERPROFILE: path.resolve(os.homedir(), '.electron-gyp'),
@ -54,9 +53,12 @@ export default async (buildPath, electronVersion, pPlatform, pArch) => {
npm_config_build_from_source: true,
}),
});
let output = '';
child.stdout.on('data', (data) => { output += data; });
child.stderr.on('data', (data) => { output += data; });
child.on('exit', async (code) => {
d('built:', path.basename(modulePath));
if (code !== 0) return reject(new Error(`Failed to rebuild: ${modulePath}`));
if (code !== 0) return reject(new Error(`Failed to rebuild: ${modulePath}\n\n${output}`));
await pify(mkdirp)(path.dirname(metaPath));
await fs.writeFile(metaPath, pArch);
resolve();