diff --git a/src/util/rebuild.js b/src/util/rebuild.js index aed4443edd..b4d704347f 100644 --- a/src/util/rebuild.js +++ b/src/util/rebuild.js @@ -28,7 +28,18 @@ export default async (buildPath, electronVersion, pPlatform, pArch) => { `--target=${electronVersion}`, `--arch=${pArch}`, '--dist-url=https://atom.io/download/electron', + '--build-from-source', ]; + + const modulePackageJSON = JSON.parse(await fs.readFile(path.resolve(modulePath, 'package.json'))); + Object.keys(modulePackageJSON.binary || {}).forEach((binaryKey) => { + let value = modulePackageJSON.binary[binaryKey]; + if (binaryKey === 'module_path') { + value = path.resolve(modulePath, value); + } + rebuildArgs.push(`--${binaryKey}=${value}`); + }); + await new Promise((resolve, reject) => { const child = spawn(process.execPath, [path.resolve(__dirname, '../../node_modules/.bin/node-gyp')].concat(rebuildArgs), { cwd: modulePath, @@ -40,6 +51,7 @@ export default async (buildPath, electronVersion, pPlatform, pArch) => { npm_config_runtime: 'electron', npm_config_arch: pArch, npm_config_target_arch: pArch, + npm_config_build_from_source: true, }), }); child.on('exit', async (code) => {