-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathperformance
45 lines (39 loc) · 1.11 KB
/
performance
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
if ! command -v npx &> /dev/null
then
echo -e "\033[1;31m Please install Node JS version 18 or Higher."
exit 1
fi
declare -a blocked_patterns=()
if [ -f ./configs/${1}.cfg ]; then
source ./configs/${1}.cfg
else
echo -e "\033[1;31m ./configs/${1}.cfg not found!"
exit 1
fi
# Set Mobile|Desktop modes
# mobile is default, no param needed
configPath="./configs/mobile.json"
media="mobile"
slowdown=${mobile_slowdown}
if [ "$2" = "desktop" ]
then
configPath="./configs/desktop.json"
media="desktop"
slowdown=${desktop_slowdown}
fi
blocked_str=""
for asset in ${blocked_patterns[@]}; do
blocked_str+=" --blocked-url-patterns=\"$asset\" "
done
# If it fails here, make sure lighthouse npm package is
# installed and node version meets requirements
npx lighthouse ${site} \
--config-path=${configPath} \
--chrome-flags="--headless" \
--output-path=./reports/report-${1}-${media}-$(date +%s).html \
--chrome-flags='--ignore-certificate-errors' \
--throttling.cpuSlowdownMultiplier=${slowdown} \
--disable-gpu \
${blocked_str} \
--view