From c1f3f37a5e6e784eaaa7d06578769d9fde6715d5 Mon Sep 17 00:00:00 2001 From: Nuri Hodges Date: Fri, 17 Nov 2017 09:39:39 -0800 Subject: [PATCH 1/2] docs: demo flags in example of programmatic use In the current documentation, the example given does not pass the flags argument to `chromeLauncher.launch` which caused some initial confusion when trying to leverage any of the chromeFlags. It is not intuitive that flags should also be passed into the launch method. --- docs/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/readme.md b/docs/readme.md index 72a2ff348e24..034d47b95f3b 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -12,7 +12,7 @@ const lighthouse = require('lighthouse'); const chromeLauncher = require('chrome-launcher'); function launchChromeAndRunLighthouse(url, flags = {}, config = null) { - return chromeLauncher.launch().then(chrome => { + return chromeLauncher.launch(flags).then(chrome => { flags.port = chrome.port; return lighthouse(url, flags, config).then(results => chrome.kill().then(() => results)); From 6d756a73bf6b1e9b3109d3a463349d75f58d2e13 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Wed, 10 Jan 2018 16:25:52 -0800 Subject: [PATCH 2/2] suggested fixes --- docs/readme.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/readme.md b/docs/readme.md index 034d47b95f3b..32e16faf9fec 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -11,20 +11,23 @@ assumes you've installed Lighthouse as a dependency (`yarn add --dev lighthouse` const lighthouse = require('lighthouse'); const chromeLauncher = require('chrome-launcher'); -function launchChromeAndRunLighthouse(url, flags = {}, config = null) { - return chromeLauncher.launch(flags).then(chrome => { - flags.port = chrome.port; - return lighthouse(url, flags, config).then(results => +function launchChromeAndRunLighthouse(url, opts, config = null) { + return chromeLauncher.launch({chromeFlags: opts.chromeFlags}).then(chrome => { + opts.port = chrome.port; + return lighthouse(url, opts, config).then(results => chrome.kill().then(() => results)); }); } -const flags = {}; +const opts = { + chromeFlags: ['--show-paint-rects'] +}; // Usage: -launchChromeAndRunLighthouse('https://example.com', flags).then(results => { +launchChromeAndRunLighthouse('https://example.com', opts).then(results => { // Use results! }); + ``` ### Performance-only Lighthouse run