Skip to content

Commit

Permalink
fixes uncaught on browser not launched and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymoulin committed Nov 15, 2017
1 parent ab2fad9 commit a6b8bf9
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ FROM femtopixel/google-lighthouse

MAINTAINER Jay MOULIN <[email protected]> <https://twitter.com/moulinjay>

USER root
#https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
RUN PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm install -g google-lighthouse-puppeteer --unsafe-perm=true
USER chrome
RUN mkdir -p /home/chrome/testcases && cd /home/chrome
RUN mkdir -p /home/chrome/testcases && cd /home/chrome && yarn add google-lighthouse-puppeteer
COPY entrypoint.sh /usr/bin/entrypoint
COPY ./bin/lighthouse-puppeteer.js /home/chrome/lighthouse-puppeteer
WORKDIR /home/chrome
VOLUME /home/chrome/testcases

Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
.PHONY=install install-npm publish publish-npm

install:
touch t.tgz
docker run --rm -v `pwd`:/app -ti -w /app node make install-npm
publish:
touch t.tgz
docker run --rm -v `pwd`:/app -ti -w /app node make publish-npm
major:
docker run --rm -v $$HOME:/root -v `pwd`:/app -ti -w /app node npm version major
Expand All @@ -13,6 +11,7 @@ minor:
patch:
docker run --rm -v $$HOME:/root -v `pwd`:/app -ti -w /app node npm version patch
clean:
touch t.tgz
rm *.tgz
rm -Rf node_modules
install-npm: clean
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,19 @@ with :

Default:

```
```json
{
debugPort:9222, //port to communicate with chrome-debug (change only if you know what you are doing)
lighthouse: {
lighthouse: { //parameters sent to lighthouse-batch
params:'', //optional parameters to be passed to lighthouse
useGlobal:true, //should use running chrome-debug or not (yes to use default, no to launch a new one with lighthouse) (change only if you know what you are doing)
out:'/home/chrome/reports', //path to export reports to
html:true, //true to export HTML reports with JSON reports, false for json only
verbose:false, //false to hide debug, true to display some more informations
},
puppeteer: { //parameters sent to puppeteer
args: [
]
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

if [[ -f "/home/chrome/testcases/$1.js" ]]; then
lighthouse-puppeteer "/home/chrome/testcases/$1.js" "{puppeteer:{executablePath: 'google-chrome'}}"
./lighthouse-puppeteer "/home/chrome/testcases/$1.js" "$2"
else
exec "$@"
fi
Expand Down
9 changes: 4 additions & 5 deletions lighthouse-puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ class LighthousePuppeteer {
verbose: false,
},
puppeteer: {
args: [
`--remote-debugging-port=${options.debugPort}`
]
args: []
}
};
this.browser = null;
}

exec(modulePath, opts = {}) {
return new Promise((resolveGlobal, reject) => {
const options = Object.assign({}, this.defaultOptions, opts);
let options = Object.assign({}, this.defaultOptions, opts);
options.puppeteer.args.push(`--remote-debugging-port=${options.debugPort}`);
const testcase = typeof (modulePath) === 'object' ? modulePath : require(modulePath);
if (typeof(testcase.connect) !== 'function') {
console.log(`${modulePath}: Module incorrectly formatted. Module should have "connect" method!`);
Expand Down Expand Up @@ -54,7 +53,7 @@ class LighthousePuppeteer {
.then(b => b.close())
.then(b => resolveGlobal)
.catch((err) => {
this.browser.close();
this.browser && this.browser.close();
reject(err);
});
});
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.2.6",
"version": "0.2.7",
"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 a6b8bf9

Please sign in to comment.