diff --git a/lighthouse-core/scripts/roll-to-devtools.sh b/lighthouse-core/scripts/roll-to-devtools.sh index b1bdfaed6494..2270d8fe963f 100755 --- a/lighthouse-core/scripts/roll-to-devtools.sh +++ b/lighthouse-core/scripts/roll-to-devtools.sh @@ -17,13 +17,12 @@ # with a custom devtools location (could be path to standalone checkout): # yarn devtools ~/code/devtools/devtools-frontend + +set -euo pipefail + check="\033[96m ✓\033[39m" -if [[ -n "$1" ]]; then - dt_dir="$1" -else - dt_dir="$HOME/src/devtools/devtools-frontend" -fi +dt_dir="${1:-$HOME/src/devtools/devtools-frontend}" if [[ ! -d "$dt_dir" || ! -a "$dt_dir/front_end/OWNERS" ]]; then echo -e "\033[31m✖ Error!\033[39m" @@ -48,10 +47,14 @@ echo -e "$check lighthouse-dt-bundle copied." # generate bundle.d.ts npx tsc --allowJs --declaration --emitDeclarationOnly dist/report/bundle.esm.js + # Exports of report/clients/bundle.js can possibly be mistakenly overriden by tsc. -sed -i '' 's/export type DOM = any;//' dist/report/bundle.esm.d.ts -sed -i '' 's/export type ReportRenderer = any;//' dist/report/bundle.esm.d.ts -sed -i '' 's/export type ReportUIFeatures = any;//' dist/report/bundle.esm.d.ts +# Funky sed inplace command so we support both GNU sed and BSD sed (used by GHA devtools runner on macos) +# https://stackoverflow.com/a/22084103/89484 +sed -i.bak 's/export type DOM = any;//' dist/report/bundle.esm.d.ts +sed -i.bak 's/export type ReportRenderer = any;//' dist/report/bundle.esm.d.ts +sed -i.bak 's/export type ReportUIFeatures = any;//' dist/report/bundle.esm.d.ts + # copy report code $fe_lh_dir fe_lh_report_dir="$fe_lh_dir/report/"