12
12
*
13
13
* To use with locally built DevTools and Lighthouse, run (assuming devtools at ~/src/devtools/devtools-frontend):
14
14
* yarn devtools
15
- * yarn run-devtools --custom-devtools-frontend=file://$HOME/src/devtools/devtools-frontend/out/Default/gen/front_end
15
+ * yarn run-devtools --chrome-flags=-- custom-devtools-frontend=file://$HOME/src/devtools/devtools-frontend/out/Default/gen/front_end
16
16
*
17
17
* Or with the DevTools in .tmp:
18
18
* bash lighthouse-core/test/chromium-web-tests/setup.sh
19
- * yarn run-devtools --custom-devtools-frontend=file://$PWD/.tmp/chromium-web-tests/devtools/devtools-frontend/out/Default/gen/front_end
19
+ * yarn run-devtools --chrome-flags=-- custom-devtools-frontend=file://$PWD/.tmp/chromium-web-tests/devtools/devtools-frontend/out/Default/gen/front_end
20
20
*
21
21
* URL list file: yarn run-devtools < path/to/urls.txt
22
22
* Single URL: yarn run-devtools "https://example.com"
@@ -30,6 +30,8 @@ import puppeteer from 'puppeteer';
30
30
import yargs from 'yargs' ;
31
31
import * as yargsHelpers from 'yargs/helpers' ;
32
32
33
+ import { parseChromeFlags } from '../../lighthouse-cli/run.js' ;
34
+
33
35
const y = yargs ( yargsHelpers . hideBin ( process . argv ) ) ;
34
36
const argv_ = y
35
37
. usage ( '$0 [url]' )
@@ -40,9 +42,9 @@ const argv_ = y
40
42
default : 'latest-run/devtools-lhrs' ,
41
43
alias : 'o' ,
42
44
} )
43
- . option ( 'custom-devtools-frontend ' , {
45
+ . option ( 'chrome-flags ' , {
44
46
type : 'string' ,
45
- alias : 'd ' ,
47
+ default : '' ,
46
48
} )
47
49
. option ( 'config' , {
48
50
type : 'string' ,
@@ -287,6 +289,7 @@ async function readUrlList() {
287
289
}
288
290
289
291
async function run ( ) {
292
+ const chromeFlags = parseChromeFlags ( argv [ 'chromeFlags' ] ) ;
290
293
const outputDir = argv [ 'output-dir' ] ;
291
294
292
295
// Create output directory.
@@ -299,7 +302,9 @@ async function run() {
299
302
fs . mkdirSync ( outputDir ) ;
300
303
}
301
304
302
- const customDevtools = argv [ 'custom-devtools-frontend' ] ;
305
+ const customDevtools = chromeFlags
306
+ . find ( f => f . startsWith ( '--custom-devtools-frontend=' ) )
307
+ ?. replace ( '--custom-devtools-frontend=' , '' ) ;
303
308
if ( customDevtools ) {
304
309
console . log ( `Using custom devtools frontend: ${ customDevtools } ` ) ;
305
310
console . log ( 'Make sure it has been built recently!' ) ;
@@ -313,7 +318,7 @@ async function run() {
313
318
314
319
const browser = await puppeteer . launch ( {
315
320
executablePath : process . env . CHROME_PATH ,
316
- args : customDevtools ? [ `--custom-devtools-frontend= ${ customDevtools } ` ] : [ ] ,
321
+ args : chromeFlags ,
317
322
devtools : true ,
318
323
} ) ;
319
324
0 commit comments