Add electron-mksnapshot and use the downloaded bin to generate snapshots

This commit is contained in:
Antonio Scandurra
2017-03-06 14:12:14 +01:00
parent 7fbe68e12e
commit f2ea38afba
3 changed files with 13 additions and 1 deletions

View File

@@ -7,16 +7,27 @@ const semver = require('semver')
module.exports = function () {
// Chromedriver should be specified as ~x.y where x and y match Electron major/minor
const chromedriverVer = buildMetadata.dependencies['electron-chromedriver']
const mksnapshotVer = buildMetadata.dependencies['electron-mksnapshot']
// Always use tilde on electron-chromedriver so that it can pick up the best patch vesion
if (!chromedriverVer.startsWith('~')) {
throw new Error(`electron-chromedriver version in script/package.json should start with a tilde to match latest patch version.`)
}
if (!mksnapshotVer.startsWith('~')) {
throw new Error(`electron-mksnapshot version in script/package.json should start with a tilde to match latest patch version.`)
}
const electronVer = CONFIG.appMetadata.electronVersion
if (!semver.satisfies(electronVer, chromedriverVer)) {
throw new Error(`electron-chromedriver ${chromedriverVer} incompatible with electron ${electronVer}.\n` +
'Did you upgrade electron in package.json and forget to upgrade electron-chromedriver in ' +
`script/package.json to '~${semver.major(electronVer)}.${semver.minor(electronVer)}' ?`)
}
if (!semver.satisfies(electronVer, mksnapshotVer)) {
throw new Error(`electron-mksnapshot ${mksnapshotVer} incompatible with electron ${electronVer}.\n` +
'Did you upgrade electron in package.json and forget to upgrade electron-mksnapshot in ' +
`script/package.json to '~${semver.major(electronVer)}.${semver.minor(electronVer)}' ?`)
}
}

View File

@@ -79,7 +79,7 @@ module.exports = function (packagedAppPath) {
const generatedStartupBlobPath = path.join(CONFIG.buildOutputPath, 'snapshot_blob.bin')
console.log(`Generating startup blob at "${generatedStartupBlobPath}"`)
childProcess.execFileSync(
path.join(CONFIG.repositoryRootPath, 'electron', 'mksnapshot', `mksnapshot`),
path.join(CONFIG.repositoryRootPath, 'script', 'node_modules', 'electron-mksnapshot', 'bin', 'mksnapshot'),
[snapshotScriptPath, '--startup_blob', generatedStartupBlobPath]
)

View File

@@ -9,6 +9,7 @@
"donna": "1.0.13",
"electron-chromedriver": "~1.3",
"electron-link": "0.0.8",
"electron-mksnapshot": "~1.3",
"electron-packager": "7.3.0",
"electron-winstaller": "2.5.1",
"fs-extra": "0.30.0",