Skip to content

Commit

Permalink
update manual-chrome-launcher with fixes from LH
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Jul 10, 2019
1 parent c044ee4 commit 90dc0e4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions manual-chrome-launcher.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env node

'use strict';
// Keep this file in sync with lighthouse
// TODO: have LH depend on this one.

/**
* @fileoverview Script to launch a clean Chrome instance on-demand.
*
Expand All @@ -17,21 +20,20 @@ require('./compiled-check.js')('./dist/chrome-launcher.js');
const {Launcher, launch} = require('./dist/chrome-launcher');

const args = process.argv.slice(2);
let chromeFlags = [];
const chromeFlags = [];
let startingUrl;
let port;
let shouldEnableExtensions;
let ignoreDefaultFlags;

if (args.length) {
const providedFlags = args.filter(flag => flag.startsWith('--'));

const portFlag = providedFlags.find(flag => flag.startsWith('--port='));
port = portFlag && parseInt(portFlag.replace('--port=', ''), 10);
if (portFlag) port = parseInt(portFlag.replace('--port=', ''), 10);

shouldEnableExtensions = !!providedFlags.find(flag => flag === '--enable-extensions');
const enableExtensions = !!providedFlags.find(flag => flag === '--enable-extensions');
// The basic pattern for enabling Chrome extensions
if (shouldEnableExtensions) {
if (enableExtensions) {
ignoreDefaultFlags = true;
chromeFlags.push(...Launcher.defaultFlags().filter(flag => flag !== '--disable-extensions'));
}
Expand All @@ -45,4 +47,6 @@ launch({
port,
ignoreDefaultFlags,
chromeFlags,
}).then(v => console.log(`✨ Chrome debugging port: ${v.port}`));
})
// eslint-disable-next-line no-console
.then(v => console.log(`✨ Chrome debugging port: ${v.port}`));

0 comments on commit 90dc0e4

Please sign in to comment.