2020-01-31 18:50:44 -05:00
|
|
|
#!/usr/bin/env node
|
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2020-01-31 18:50:44 -05:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
2020-03-02 12:35:30 -05:00
|
|
|
'use strict';
|
2020-01-31 18:50:44 -05:00
|
|
|
// Use process.cwd() so that this script is portable and can be used in /aio
|
|
|
|
// where this will require /aio/node_modules/puppeteer
|
2020-02-13 09:46:38 -05:00
|
|
|
const puppeteerPkgPath = require.resolve('puppeteer/package.json', {paths: [process.cwd()]});
|
|
|
|
const puppeteerVersion = require(puppeteerPkgPath).version;
|
2021-04-03 09:52:53 -04:00
|
|
|
const chromedriverVersionMap = require('./puppeteer-chromedriver-versions');
|
2020-01-31 18:50:44 -05:00
|
|
|
const spawnSync = require('child_process').spawnSync;
|
|
|
|
|
2021-04-03 09:52:53 -04:00
|
|
|
const version = chromedriverVersionMap[puppeteerVersion];
|
2020-01-31 18:50:44 -05:00
|
|
|
if (!version) {
|
2021-04-03 09:52:53 -04:00
|
|
|
console.error(`[webdriver-manager-update.js] Error: Could not find ChromeDriver version for Puppeteer version '${
|
|
|
|
puppeteerVersion}' in ChromeDriver/Puppeteer version map. Please update /scripts/puppeteer-chromedriver-versions.js.`);
|
2020-01-31 18:50:44 -05:00
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
const args = [
|
2020-02-13 09:46:38 -05:00
|
|
|
'webdriver-manager',
|
2020-01-31 18:50:44 -05:00
|
|
|
'update',
|
|
|
|
'--gecko=false',
|
|
|
|
'--standalone=false',
|
|
|
|
'--versions.chrome',
|
|
|
|
version,
|
|
|
|
// Append additional user arguments after script default arguments
|
|
|
|
...process.argv.slice(2),
|
|
|
|
];
|
|
|
|
|
2020-02-13 09:46:38 -05:00
|
|
|
const result = spawnSync('yarn', args, {shell: true, stdio: 'inherit'});
|
2020-01-31 18:50:44 -05:00
|
|
|
if (result.error) {
|
2020-05-05 16:12:39 -04:00
|
|
|
console.error(`[webdriver-manager-update.js] Call to 'yarn ${
|
|
|
|
args.join(' ')}' failed with error code ${result.error.code}`);
|
2020-01-31 18:50:44 -05:00
|
|
|
process.exit(result.status);
|
|
|
|
}
|
|
|
|
if (result.status) {
|
2020-05-05 16:12:39 -04:00
|
|
|
console.error(`[webdriver-manager-update.js] Call to 'yarn ${
|
|
|
|
args.join(' ')}' failed with error code ${result.status}`);
|
2020-01-31 18:50:44 -05:00
|
|
|
process.exit(result.status);
|
2020-02-13 09:46:38 -05:00
|
|
|
}
|