Skip to content

Commit

Permalink
Update root readme with how to use launcher.
Browse files Browse the repository at this point in the history
  • Loading branch information
samccone committed May 14, 2017
1 parent e6c9831 commit d0a0172
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,19 @@ assumes you've installed Lighthouse as a dependency (`yarn add --dev lighthouse`

```javascript
const lighthouse = require('lighthouse');
const ChromeLauncher = require('lighthouse/lighthouse-cli/chrome-launcher.js').ChromeLauncher;
const ChromeLauncher = require('lighthouse/chrome-laucher/chrome-launcher.js');
const Printer = require('lighthouse/lighthouse-cli/printer');

function launchChromeAndRunLighthouse(url, flags, config) {
const launcher = new ChromeLauncher({port: 9222, autoSelectChrome: true});
const launchedChrome = ChromeLauncher.launch();

return launcher.run() // Launch Chrome.
launchedChrome
.then(() => lighthouse(url, flags, config)) // Run Lighthouse.
.then(results => launcher.kill().then(() => results)) // Kill Chrome and return results.
.then(results => launchedChrome.kill())
.then(() => results)) // Kill Chrome and return results.
.catch(err => {
// Kill Chrome if there's an error.
return launcher.kill().then(() => {
return launchedChrome.kill().then(() => {
throw err;
});
});
Expand Down

0 comments on commit d0a0172

Please sign in to comment.