diff --git a/script/lib/generate-startup-snapshot.js b/script/lib/generate-startup-snapshot.js index 471bd1201..bb635b4c1 100644 --- a/script/lib/generate-startup-snapshot.js +++ b/script/lib/generate-startup-snapshot.js @@ -3,7 +3,6 @@ const fs = require('fs') const path = require('path') const electronLink = require('electron-link') const CONFIG = require('../config') -const vm = require('vm') module.exports = function (packagedAppPath) { const snapshotScriptPath = path.join(CONFIG.buildOutputPath, 'startup.js') @@ -76,7 +75,20 @@ module.exports = function (packagedAppPath) { process.stdout.write('\n') console.log('Verifying if snapshot can be executed via `mksnapshot`') - vm.runInNewContext(snapshotScript, undefined, {filename: snapshotScriptPath, displayErrors: true}) + const verifySnapshotScriptPath = path.join(CONFIG.repositoryRootPath, 'script', 'verify-snapshot-script') + let nodeBundledInElectronPath + if (process.platform === 'darwin') { + nodeBundledInElectronPath = path.join(packagedAppPath, 'Contents', 'MacOS', 'Atom') + } else if (process.platform === 'win32') { + nodeBundledInElectronPath = path.join(packagedAppPath, 'atom.exe') + } else { + nodeBundledInElectronPath = path.join(packagedAppPath, 'atom') + } + childProcess.execFileSync( + nodeBundledInElectronPath, + [verifySnapshotScriptPath, snapshotScriptPath], + {env: Object.assign({}, process.env, {ELECTRON_RUN_AS_NODE: 1})} + ) const generatedStartupBlobPath = path.join(CONFIG.buildOutputPath, 'snapshot_blob.bin') console.log(`Generating startup blob at "${generatedStartupBlobPath}"`) diff --git a/script/verify-snapshot-script b/script/verify-snapshot-script new file mode 100755 index 000000000..7fddbb1b9 --- /dev/null +++ b/script/verify-snapshot-script @@ -0,0 +1,6 @@ +#!/usr/bin/env node +const fs = require('fs') +const vm = require('vm') +const snapshotScriptPath = process.argv[2] +const snapshotScript = fs.readFileSync(snapshotScriptPath, 'utf8') +vm.runInNewContext(snapshotScript, undefined, {filename: snapshotScriptPath, displayErrors: true})