Skip to content
Permalink
Browse files

refactor(packager): make the rebuild a promise and use an ora

  • Loading branch information
MarshallOfSound authored and malept committed Dec 11, 2016
1 parent 1d1ff74 commit bc1ec28d6c20b555aa966a3adf0925becef131b2
Showing with 17 additions and 7 deletions.
  1. +5 −2 src/electron-forge-package.js
  2. +1 −2 src/electron-forge-start.js
  3. +11 −3 src/util/rebuild.js
@@ -61,8 +61,11 @@ const main = async () => {
}, async (...args) => {
prepareSpinner.succeed();
await packagerCompileHook(dir, ...args);
packagerSpinner = ora.ora('Packaging Application');
}, rebuildHook].concat(forgeConfig.electronPackagerConfig.afterCopy ? forgeConfig.electronPackagerConfig.afterCopy.map(item => require(item)) : []),
}, async (buildPath, electronVersion, pPlatform, pArch, done) => {
await rebuildHook(buildPath, electronVersion, pPlatform, pArch);
packagerSpinner = ora.ora('Packaging Application').start();
done();
}].concat(forgeConfig.electronPackagerConfig.afterCopy ? forgeConfig.electronPackagerConfig.afterCopy.map(item => require(item)) : []),
afterExtract: forgeConfig.electronPackagerConfig.afterExtract ? forgeConfig.electronPackagerConfig.afterExtract.map(item => require(item)) : [],
dir,
arch,
@@ -4,7 +4,6 @@ import fs from 'fs-promise';
import path from 'path';
import program from 'commander';
import ora from 'ora';
import pify from 'pify';

import './util/terminate';
import rebuild from './util/rebuild';
@@ -37,7 +36,7 @@ const main = async () => {

const packageJSON = JSON.parse(await fs.readFile(path.resolve(dir, 'package.json'), 'utf8'));

await pify(rebuild)(dir, packageJSON.devDependencies['electron-prebuilt-compile'], process.platform, process.arch);
await rebuild(dir, packageJSON.devDependencies['electron-prebuilt-compile'], process.platform, process.arch);
spawn(process.execPath, [path.resolve(dir, 'node_modules/.bin/electron'), '.'].concat(process.argv.slice(2)), {
cwd: dir,
stdio: 'inherit',
@@ -2,14 +2,16 @@ import { spawn } from 'child_process';
import debug from 'debug';
import fs from 'fs-promise';
import mkdirp from 'mkdirp';
import ora from 'ora';
import os from 'os';
import path from 'path';
import pify from 'pify';

const d = debug('electron-forge:rebuild');

export default async (buildPath, electronVersion, pPlatform, pArch, done) => {
export default async (buildPath, electronVersion, pPlatform, pArch) => {
const rebuilds = [];

const rebuildModuleAt = async (modulePath) => {
if (await fs.exists(path.resolve(modulePath, 'binding.gyp'))) {
const metaPath = path.resolve(modulePath, 'build', 'Release', '.forge-meta');
@@ -58,7 +60,13 @@ export default async (buildPath, electronVersion, pPlatform, pArch, done) => {
}
}
};
const nativeSpinner = ora.ora('Preparing native dependencies').start();
rebuildAllModulesIn(path.resolve(buildPath, 'node_modules'));
await Promise.all(rebuilds);
done();
try {
await Promise.all(rebuilds);
} catch (err) {
nativeSpinner.fail();
throw err;
}
nativeSpinner.succeed();
};

0 comments on commit bc1ec28

Please sign in to comment.
You can’t perform that action at this time.