-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nightwatch): should not install corresponding webdriver if the br…
…owser is unselected (#5528)
- Loading branch information
1 parent
a41cac2
commit 795b277
Showing
1 changed file
with
17 additions
and
14 deletions.
There are no files selected for viewing
31 changes: 17 additions & 14 deletions
31
packages/@vue/cli-plugin-e2e-nightwatch/generator/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
const { installedBrowsers } = require('@vue/cli-shared-utils') | ||
|
||
module.exports = api => { | ||
module.exports = (api, { webdrivers }) => { | ||
api.render('./template', { | ||
hasTS: api.hasPlugin('typescript'), | ||
hasESLint: api.hasPlugin('eslint') | ||
}) | ||
|
||
const devDependencies = {} | ||
|
||
// Use devDependencies to store latest version number so as to automate update | ||
const devDeps = require('../package.json').devDependencies | ||
const geckodriver = devDeps.geckodriver | ||
const pluginDeps = require('../package.json').devDependencies | ||
|
||
// chromedriver major version bumps every 6 weeks following Chrome | ||
// so there may be a mismatch between | ||
// user's installed browser version and the default provided version | ||
// fallback to the devDependencies version in case detection fails | ||
const chromedriver = installedBrowsers.chrome | ||
? installedBrowsers.chrome.match(/^(\d+)\./)[1] | ||
: devDeps.chromedriver | ||
if (webdrivers && webdrivers.includes('firefox')) { | ||
devDependencies.geckodriver = pluginDeps.geckodriver | ||
} | ||
if (webdrivers && webdrivers.includes('chrome')) { | ||
// chromedriver major version bumps every 6 weeks following Chrome | ||
// so there may be a mismatch between | ||
// user's installed browser version and the default provided version | ||
// fallback to the devDependencies version in case detection fails | ||
devDependencies.chromedriver = installedBrowsers.chrome | ||
? installedBrowsers.chrome.match(/^(\d+)\./)[1] | ||
: pluginDeps.chromedriver | ||
} | ||
|
||
api.extendPackage({ | ||
scripts: { | ||
'test:e2e': 'vue-cli-service test:e2e' | ||
}, | ||
devDependencies: { | ||
chromedriver, | ||
geckodriver | ||
} | ||
devDependencies | ||
}) | ||
} |