-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlighthouse-quiet
More file actions
executable file
·18 lines (16 loc) · 1016 Bytes
/
lighthouse-quiet
File metadata and controls
executable file
·18 lines (16 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
# Guarantees stdout is ONLY a valid Lighthouse JSON report — nothing else.
# Intended for programmatic callers that pipe our stdout straight into a JSON
# parser: any stray warning/log line in the stream would corrupt the output.
#
# Strategy: force --output=json --output-path=<file>, silence all other output,
# then cat the file. If lighthouse fails the file won't exist and cat exits
# non-zero, so the caller sees a clean failure instead of partial JSON.
#
# Note: `lighthouse --quiet --output-path=stdout` looks like it would do the
# same thing, but relying on the upstream CLI to never leak anything to stdout
# has historically broken (e.g. regression in 12.6.0). This wrapper is
# defense-in-depth; do not remove it just because --quiet looks clean today.
cd reports
/opt/node_modules/.bin/lighthouse "$@" --chrome-flags="--headless --no-sandbox --disable-dev-shm-usage --disable-gpu" --no-enable-error-reporting --output=json --output-path=result.json >/dev/null 2>&1
exec cat result.json