Ensure chromedriver matches electron version during build

This commit is contained in:
Damien Guard
2016-12-13 10:13:22 -08:00
parent f25a718c02
commit aa2b32e29c
3 changed files with 25 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ const argv = yargs
.wrap(yargs.terminalWidth())
.argv
const checkChromedriverVersion = require('./lib/check-chromedriver-version')
const cleanOutputDirectory = require('./lib/clean-output-directory')
const codeSignOnMac = require('./lib/code-sign-on-mac')
const compressArtifacts = require('./lib/compress-artifacts')
@@ -47,6 +48,7 @@ process.on('unhandledRejection', function (e) {
process.exit(1)
})
checkChromedriverVersion()
cleanOutputDirectory()
copyAssets()
transpileBabelPaths()

View File

@@ -0,0 +1,22 @@
'use strict'
const buildMetadata = require('../package.json')
const CONFIG = require('../config')
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']
// 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.`)
}
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)}' ?`)
}
}

View File

@@ -8,7 +8,7 @@
"colors": "1.1.2",
"csslint": "1.0.2",
"donna": "1.0.13",
"electron-chromedriver": "^1.3.0",
"electron-chromedriver": "~1.3",
"electron-packager": "7.3.0",
"electron-winstaller": "2.5.0",
"fs-extra": "0.30.0",