2020-01-31 18:50:44 -05:00
#!/usr/bin/env node
'use strict' ;
/ * *
* @ license
* Copyright Google Inc . 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 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 ;
2020-01-31 18:50:44 -05:00
const chromeVersionMap = require ( './puppeteer-chrome-versions' ) ;
const spawnSync = require ( 'child_process' ) . spawnSync ;
const version = chromeVersionMap [ puppeteerVersion ] ;
if ( ! version ) {
2020-02-13 09:46:38 -05:00
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. ` ) ;
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-02-13 09:46:38 -05: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-02-13 09:46:38 -05: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
}