-
Notifications
You must be signed in to change notification settings - Fork 191
/
manual-chrome-launcher.js
executable file
·41 lines (33 loc) · 1.11 KB
/
manual-chrome-launcher.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
#!/usr/bin/env node
'use strict';
/**
* @fileoverview Script to launch a clean Chrome instance on-demand.
*
* Assuming Lighthouse is installed globally or `npm link`ed, use via:
* chrome-debug
* Optionally enable extensions or pass a port, additional chrome flags, and/or a URL
* chrome-debug --port=9222
* chrome-debug http://goat.com
* chrome-debug --show-paint-rects
* chrome-debug --enable-extensions
*/
require('./compiled-check.js')('chrome-launcher.js');
const {launch} = require('./chrome-launcher');
const args = process.argv.slice(2);
let chromeFlags;
let startingUrl;
let port;
let enableExtensions;
if (args.length) {
chromeFlags = args.filter(flag => flag.startsWith('--'));
const portFlag = chromeFlags.find(flag => flag.startsWith('--port='));
port = portFlag && portFlag.replace('--port=', '');
enableExtensions = !!chromeFlags.find(flag => flag === '--enable-extensions');
startingUrl = args.find(flag => !flag.startsWith('--'));
}
launch({
startingUrl,
port,
enableExtensions,
chromeFlags,
}).then(v => console.log(`✨ Chrome debugging port: ${v.port}`));