Skip to content

Commit

Permalink
Fixes boolean puppeteer parameters when no value sent + add lighthous…
Browse files Browse the repository at this point in the history
…e documentation
  • Loading branch information
jaymoulin committed Nov 17, 2017
1 parent 535e8d4 commit c4b3e72
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Google Lighthouse Puppeteer - Docker Image
============================================
==========================================

[![latest release](https://img.shields.io/github/release/femtopixel/docker-google-lighthouse-puppeteer.svg "latest release")](http://github.com/femtopixel/docker-google-lighthouse-puppeteer/releases)
[![NPM release](https://img.shields.io/npm/v/google-lighthouse-puppeteer.svg "NPM release")](https://www.npmjs.com/package/google-lighthouse-puppeteer)
Expand Down Expand Up @@ -88,8 +88,7 @@ Puppeteer

```javascript
const lp = require('google-lighthouse-puppeteer');
const options = {};
lp.exec('/path/to/my/test.js', options)
const options = {};lp.exec('/path/to/my/test.js', options)
.then(() => console.log('everything ok'))
.catch((err) => console.error(err));
```
Expand All @@ -101,21 +100,27 @@ You can change some options like in CLI :
{
"main": {
"port":9222,
"verbose":[true, true] //the more you add true, the more the verbosity
"verbose":[true, true]
},
"lighthouse": {
"params":"",
"output_directory":"/home/chrome/reports",
"lighthouse_params":""
},
"_unknown": [ //for puppeteer
"_unknown": [
"--puppeteer-ignoreHTTPSErrors",
"--puppeteer-slowMo",
"20"
]
}
```

For puppeteer, all params must be added in the `_unknown` entry and are prefixed with `--puppeteer-`. Each value must be in separated entry.

`verbose` is an array of true, the more `true` the more talkative the application.

Lighthouse params can be added respecting [their documentation](https://github.com/GoogleChrome/lighthouse/tree/master/docs)

### API

You should create a testcase file named `whateverYouWant.js`.
Expand Down
1 change: 1 addition & 0 deletions bin/lighthouse-puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const optionDefinitions = [
name: 'lighthouse_params',
alias: 'l',
description: 'Optional parameters to pass to lighthouse' +
'\n(https://github.com/GoogleChrome/lighthouse/tree/master/docs)',
'\n([italic]{example}: "--quiet --perf")',
group: 'lighthouse'
},
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LighthousePuppeteer {
if (opts[name].startsWith('--puppeteer-')) {
const param = opts[name].replace('--puppeteer-', '');
const nextParam = opts[name - -1];
this.options.puppeteer[param] = nextParam.startsWith('--puppeteer-') || (nextParam || true);
this.options.puppeteer[param] = nextParam && !nextParam.startsWith('--puppeteer-') ? nextParam : true;
}
}
return this;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "google-lighthouse-puppeteer",
"version": "0.3.0",
"version": "0.3.1",
"description": "Google Lighthouse Puppeteer is a package to generate reports on multiple urls that allows or not authentication",
"main": "lighthouse-puppeteer.js",
"scripts": {
Expand Down

0 comments on commit c4b3e72

Please sign in to comment.