forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathwebdriver-manager-update.js
45 lines (42 loc) · 1.59 KB
/
webdriver-manager-update.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env node
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* 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
*/
'use strict';
// Use process.cwd() so that this script is portable and can be used in /aio
// where this will require /aio/node_modules/puppeteer
const puppeteerPkgPath = require.resolve('puppeteer/package.json', {paths: [process.cwd()]});
const puppeteerVersion = require(puppeteerPkgPath).version;
const chromeVersionMap = require('./puppeteer-chrome-versions');
const spawnSync = require('child_process').spawnSync;
const version = chromeVersionMap[puppeteerVersion];
if (!version) {
console.error(`[webdriver-manager-update.js] Error: Could not find Chrome version for Puppeteer version '${
puppeteerVersion}' in Chrome/Puppeteer version map. Please update /scripts/puppeteer-chrome-versions.js.`);
process.exit(1);
}
const args = [
'webdriver-manager',
'update',
'--gecko=false',
'--standalone=false',
'--versions.chrome',
version,
// Append additional user arguments after script default arguments
...process.argv.slice(2),
];
const result = spawnSync('yarn', args, {shell: true, stdio: 'inherit'});
if (result.error) {
console.error(`[webdriver-manager-update.js] Call to 'yarn ${
args.join(' ')}' failed with error code ${result.error.code}`);
process.exit(result.status);
}
if (result.status) {
console.error(`[webdriver-manager-update.js] Call to 'yarn ${
args.join(' ')}' failed with error code ${result.status}`);
process.exit(result.status);
}