Last active
December 21, 2018 09:44
-
-
Save SGudbrandsson/051baa90e16a77fd3bf4ca2a67dedf90 to your computer and use it in GitHub Desktop.
Bash quick function for lighthouse audits (skipping network load)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Run a lighthouse audit and open it in a new tab in Chrome | |
# This uses Docker for consistency | |
# Only the performance test is run | |
# | |
# USAGE: | |
# lighthouse production mobile https://google.com | |
# lighthouse mobile https://google.com | |
# lighthouse desktop https://google.com | |
# | |
function lighthouse() | |
{ | |
TYPE=$1 | |
SITE=$2 | |
OPTIONS="--skip-audits byte-efficiency/total-byte-weight" | |
if [[ $1 = "production" ]]; then | |
TYPE=$2 | |
SITE=$3 | |
OPTIONS="" | |
fi | |
if [[ $TYPE = "mobile" || $TYPE = "desktop" ]]; then | |
OPTIONS="$OPTIONS --output html --emulated-form-factor $TYPE --output-path ./lighthouse-results.html" | |
mkdir -p $HOME/reports; chmod o+w $HOME/reports; docker run --rm --name lighthouse -it -v $HOME/reports:/home/chrome/reports --cap-add=SYS_ADMIN femtopixel/google-lighthouse $SITE $OPTIONS | |
google-chrome $HOME/reports/lighthouse-results.html | |
return | |
fi | |
# Run the docker image with full function parameters | |
docker run --rm --name lighthouse -it -v $HOME/reports:/home/chrome/reports --cap-add=SYS_ADMIN femtopixel/google-lighthouse $@ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment