Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function rebuildModules(buildPath) {
if (process.platform === 'darwin') {
return rebuild({
buildPath,
// eslint-disable-next-line
electronVersion: require('electron/package.json').version,
extraModules: [],
force: true,
types: ['prod', 'optional'],
});
}
}
grunt.registerTask('rebuild-native-modules', 'Rebuild native modules', function() {
const done = this.async();
const rebuildOptions = {
buildPath: __dirname,
electronVersion: '6.0.2'
};
// don't rebuild the optionalDependencies since they're only used
// on non-Windows systems
if (process.platform === 'win32') {
rebuildOptions.types = ['prod'];
}
electronRebuild.rebuild(rebuildOptions).then(() => {
grunt.log.writeln('Rebuild successful!');
done();
}).catch(e => {
grunt.log.error('Rebuilding failed!');
grunt.log.error(e);
done();
});
});
fs.writeFileSync(
path.join(outRoot, 'package.json'),
JSON.stringify(updatedPackage)
);
fs.removeSync(path.resolve(outRoot, 'node_modules'));
if (
Object.keys(newDependencies).length ||
Object.keys(newDevDependencies).length
) {
console.log(' Installing npm dependencies…');
cp.execSync('npm install', { cwd: outRoot, env: process.env });
console.log('Rebuild Realm');
rebuild({
buildPath: outRoot,
electronVersion: buildPackage.dependencies.electron.substr(1),
onlyModules: ['realm']
})
.then(() => {
console.info('Rebuild Successful');
packageApp((err, appPaths) => {
if (err) {
console.error(err);
process.exit(1);
} else {
console.log(`Built to ${appPaths}`);
}
});
})
.catch(e => {
if(!fs.existsSync(electronPath))
electronPath = null;
return electronPath;
}
console.log('Rebuilding native modules...');
const electronBase = locateElectronBase();
const electronPkg = JSON.parse(fs.readFileSync(path.join(electronBase, 'package.json')));
const electronVer = electronPkg.version;
console.log(`Electron version: ${electronVer}`);
const headerURL = process.env.ELECTRON_HEADER;
rebuild({
buildPath: path.resolve(__dirname, '..'),
electronVersion: electronVer,
headerURL,
})
.then(() => console.info('Rebuild successful'))
.catch(e => {
console.error(e);
});
(buildPath, electronVersion, platform, arch, callback) => {
rebuild({ buildPath, electronVersion, arch })
.then(() => callback())
.catch((error) => callback(error));
}
],