Skip to content

Commit 6df6b0e

Browse files
authored
launcher: support custom port via chrome-debug binary (#2644)
1 parent 3f143b1 commit 6df6b0e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env node
22

3-
'use strict'
3+
'use strict';
44
/**
55
* @fileoverview Script to launch a clean Chrome instance on-demand.
6+
*
67
* Assuming Lighthouse is installed globally or `npm link`ed, use via:
78
* chrome-debug
8-
* Optionally pass additional flags and/or a URL
9+
* Optionally pass additional a port, chrome flags and/or a URL
10+
* chrome-debug --port=9222
911
* chrome-debug http://goat.com
1012
* chrome-debug --show-paint-rects
1113
*/
@@ -16,15 +18,19 @@ const args = process.argv.slice(2);
1618

1719
let chromeFlags;
1820
let startingUrl;
21+
let port;
1922

2023
if (args.length) {
2124
chromeFlags = args.filter(flag => flag.startsWith('--'));
25+
port = chromeFlags.find(flag => flag.startsWith('--port=')).replace('--port=', '');
26+
2227
startingUrl = args.find(flag => !flag.startsWith('--'));
2328
}
2429

2530
const {launch} = require('./chrome-launcher');
2631

2732
launch({
2833
startingUrl,
34+
port,
2935
chromeFlags,
30-
}).then(v => console.log(`✨ Chrome debugging port: ${v.port}`))
36+
}).then(v => console.log(`✨ Chrome debugging port: ${v.port}`));

0 commit comments

Comments
 (0)