From c4b3e72dd92f1076dc1e81ce156179c282335218 Mon Sep 17 00:00:00 2001 From: Jay MOULIN Date: Fri, 17 Nov 2017 12:32:53 +0100 Subject: [PATCH] Fixes boolean puppeteer parameters when no value sent + add lighthouse documentation --- README.md | 15 ++++++++++----- bin/lighthouse-puppeteer.js | 1 + lighthouse-puppeteer.js | 2 +- package.json | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index dd1c3cc..c161a92 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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)); ``` @@ -101,14 +100,14 @@ 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" @@ -116,6 +115,12 @@ You can change some options like in CLI : } ``` +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`. diff --git a/bin/lighthouse-puppeteer.js b/bin/lighthouse-puppeteer.js index 70a9e9a..6e8e255 100755 --- a/bin/lighthouse-puppeteer.js +++ b/bin/lighthouse-puppeteer.js @@ -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' }, diff --git a/lighthouse-puppeteer.js b/lighthouse-puppeteer.js index 8da376a..33756de 100755 --- a/lighthouse-puppeteer.js +++ b/lighthouse-puppeteer.js @@ -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; diff --git a/package.json b/package.json index 2412bf5..dd488fd 100644 --- a/package.json +++ b/package.json @@ -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": {