fix(packager): rebuild pre-gyp modules with their binary variables

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

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

@ -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) => {