Skip to content
This repository was archived by the owner on Mar 14, 2020. It is now read-only.

Commit 0af24dc

Browse files
authored
Merge pull request #27 from joytocode/v3
feat: make v3 official
2 parents 4da14cb + 0cb310b commit 0af24dc

7 files changed

Lines changed: 6768 additions & 225 deletions

File tree

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
Run [Google Chrome Lighthouse](https://github.com/GoogleChrome/lighthouse) on [AWS Lambda](https://aws.amazon.com/lambda/).
33

44
## Versions
5-
Since 2.x, `lighthouse-lambda` has the same major version of [lighthouse](https://www.npmjs.com/package/lighthouse). For example, `lighthouse-lambda` 2.x will use `lighthouse` 2.x.
5+
Since version 2.x, `lighthouse-lambda` has the same major version of [lighthouse](https://www.npmjs.com/package/lighthouse). For example, `lighthouse-lambda` 3.x will use `lighthouse` 3.x.
66

7-
This README is for version 2.x. To see version 3.x, visit https://github.com/joytocode/lighthouse-lambda/tree/v3.
7+
This README is for version 3.x. To see older versions, visit:
8+
9+
- 2.x: https://github.com/joytocode/lighthouse-lambda/tree/archived-v2
810

911
## Installation
1012

@@ -24,12 +26,10 @@ const createLighthouse = require('lighthouse-lambda')
2426
exports.handler = function (event, context, callback) {
2527
Promise.resolve()
2628
.then(() => createLighthouse('https://example.com', { logLevel: 'info' }))
27-
.then(({ chrome, start, createReport }) => {
29+
.then(({ chrome, start }) => {
2830
return start()
2931
.then((results) => {
3032
// Do something with `results`
31-
const html = createReport(results)
32-
// Do something with the html report
3333
return chrome.kill().then(() => callback(null))
3434
})
3535
.catch((error) => {
@@ -73,9 +73,7 @@ Returns a `Promise` of an Object with the following fields:
7373

7474
- `chrome`: an instance of [`chromeLauncher.launch()`](https://github.com/GoogleChrome/chrome-launcher#launchopts).
7575
- `log`: an instance of [lighthouse-logger](https://github.com/GoogleChrome/lighthouse/tree/master/lighthouse-logger) (only if you set `options.logLevel`).
76-
- `start(options)`: a function to start the scan which returns a `Promise` of Lighthouse results.
77-
- `options.saveArtifacts`: a flag to indicate whether result artifacts should be saved (default: `false`).
78-
- `createReport(results)`: a function to create html report from Lighthouse results.
76+
- `start()`: a function to start the scan which returns a `Promise` of Lighthouse results.
7977

8078
## License
8179

lib/index.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const path = require('path')
22
const chromeLauncher = require('chrome-launcher')
33
const lighthouse = require('lighthouse')
4-
const ReportGenerator = require('lighthouse/lighthouse-core/report/v2/report-generator')
54
const chromeConfig = require('./chromeConfig')
65

76
module.exports = function createLighthouse (url, options = {}, config) {
7+
options.output = options.output || 'html'
88
const log = options.logLevel ? require('lighthouse-logger') : null
99
if (log) {
1010
log.setLevel(options.logLevel)
@@ -17,20 +17,9 @@ module.exports = function createLighthouse (url, options = {}, config) {
1717
return {
1818
chrome,
1919
log,
20-
createReport,
21-
start ({ saveArtifacts = false } = {}) {
20+
start () {
2221
return lighthouse(url, options, config)
23-
.then((results) => {
24-
if (!saveArtifacts) {
25-
delete results.artifacts
26-
}
27-
return results
28-
})
2922
}
3023
}
3124
})
3225
}
33-
34-
function createReport (results) {
35-
return new ReportGenerator().generateReportHtml(results)
36-
}

0 commit comments

Comments
 (0)