Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ The `@browserless/cli` package allows you to:
| `status <url>` | Get the HTTP status code |
| `goto <url>` | Navigate to a URL and return page/response info |

> **Note:** The `lighthouse` command requires an extra installation.
>
> Please make sure to install the standalone package by running:<br>
> <kbd>npm install -g @browserless/lighthouse</kbd>

### How it fits in the monorepo
This package depends on:

Expand Down
15 changes: 14 additions & 1 deletion packages/cli/src/commands/lighthouse.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
'use strict'

const createLighthouse = require('../../../lighthouse/src')
const { existsSync } = require('fs')
const { resolve } = require('path')

const lighthousePath = resolve(__dirname, '../../../lighthouse/src')

let createLighthouse

if (existsSync(lighthousePath)) {
createLighthouse = require(lighthousePath)
} else {
console.error('The @browserless/lighthouse package is not installed.')
console.error('Please install it by running: npm install -g @browserless/lighthouse')
process.exit(1)
}

module.exports = async ({ url, browserless, opts }) => {
const lighthouse = createLighthouse(async teardown => {
Expand Down