@browserless/lighthouse 9.6.5 → 9.7.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@browserless/lighthouse",
3
3
  "description": "Browserless Lighthouse integration using puppeteer.",
4
4
  "homepage": "https://browserless.js.org",
5
- "version": "9.6.5",
5
+ "version": "9.7.0-beta.0",
6
6
  "main": "src",
7
7
  "repository": {
8
8
  "type": "git",
@@ -24,11 +24,9 @@
24
24
  "stats"
25
25
  ],
26
26
  "dependencies": {
27
- "@browserless/errors": "^9.6.5",
27
+ "@browserless/errors": "9.6.6",
28
28
  "debug-logfmt": "~1.0.4",
29
- "execa": "~5.1.1",
30
29
  "lighthouse": "~9.6.2",
31
- "p-event": "~4.2.0",
32
30
  "p-retry": "~4.6.1",
33
31
  "p-timeout": "~4.1.0",
34
32
  "serialize-error": "~8.1.0"
@@ -44,12 +42,13 @@
44
42
  "src"
45
43
  ],
46
44
  "scripts": {
47
- "test": "NODE_ENV=test ava --concurrency 2"
45
+ "test": "ava"
48
46
  },
49
47
  "license": "MIT",
50
48
  "ava": {
51
- "timeout": "2m",
49
+ "serial": true,
50
+ "timeout": "30s",
52
51
  "verbose": true
53
52
  },
54
- "gitHead": "e31274882aa88167c98826fed9368e5adcfe270b"
53
+ "gitHead": "9ad58b35b63036848f22662a04ed913e364e1297"
55
54
  }
package/src/index.js CHANGED
@@ -2,14 +2,10 @@
2
2
 
3
3
  const { ensureError, browserTimeout } = require('@browserless/errors')
4
4
  const debug = require('debug-logfmt')('browserless:lighthouse')
5
- const { driver } = require('browserless')
6
5
  const pTimeout = require('p-timeout')
7
6
  const pRetry = require('p-retry')
8
- const pEvent = require('p-event')
9
- const execa = require('execa')
10
- const path = require('path')
11
7
 
12
- const lighthousePath = path.resolve(__dirname, 'lighthouse.js')
8
+ const lighthouse = require('./lighthouse')
13
9
 
14
10
  const { AbortError } = pRetry
15
11
 
@@ -47,20 +43,12 @@ module.exports = async (
47
43
  const browserlessPromise = getBrowserless()
48
44
  const config = getConfig(opts)
49
45
  let isRejected = false
50
- let subprocess
51
46
 
52
47
  async function run () {
53
48
  const browserless = await browserlessPromise
54
49
  const browser = await browserless.browser()
55
50
  const flags = await getFlags(browser, { disableStorageReset, logLevel, output })
56
-
57
- subprocess = execa.node(lighthousePath, { detached: process.platform !== 'win32' })
58
- subprocess.stderr.pipe(process.stderr)
59
- debug('spawn', { pid: subprocess.pid })
60
- subprocess.send({ url, flags, config })
61
-
62
- const { value, reason, isFulfilled } = await pEvent(subprocess, 'message')
63
- await driver.close(subprocess)
51
+ const { value, reason, isFulfilled } = await lighthouse({ url, flags, config })
64
52
  if (isFulfilled) return value
65
53
  throw ensureError(reason)
66
54
  }
@@ -79,7 +67,6 @@ module.exports = async (
79
67
 
80
68
  const result = await pTimeout(task(), timeout, () => {
81
69
  isRejected = true
82
- if (subprocess) subprocess.kill('SIGKILL')
83
70
  throw browserTimeout({ timeout })
84
71
  })
85
72
 
package/src/lighthouse.js CHANGED
@@ -3,7 +3,7 @@
3
3
  const { serializeError } = require('serialize-error')
4
4
  const lighthouse = require('lighthouse')
5
5
 
6
- const runLighthouse = async ({ url, flags, config }) => {
6
+ module.exports = async ({ url, flags, config }) => {
7
7
  try {
8
8
  const { lhr, report } = await lighthouse(url, flags, config)
9
9
  const value = flags.output === 'json' ? lhr : report
@@ -21,5 +21,3 @@ const runLighthouse = async ({ url, flags, config }) => {
21
21
  }
22
22
  }
23
23
  }
24
-
25
- process.on('message', async opts => process.send(await runLighthouse(opts)))