Skip to content

Instantly share code, notes, and snippets.

@defaye
Created February 6, 2024 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defaye/f664353bfbd0c08707925a03a81b2ccb to your computer and use it in GitHub Desktop.
Save defaye/f664353bfbd0c08707925a03a81b2ccb to your computer and use it in GitHub Desktop.
open code coverage report
open_coverage_report() {
# Find the coverage/index.html file, excluding node_modules and prioritizing higher-level directories
local file=$(find . -type d -name "node_modules" -prune -o -type f -name "index.html" -path "*/coverage/*" -print | head -n 1)
# Check if the file was found
if [[ -n "$file" ]]; then
# Open the file in the default browser or Firefox if the default is not set
open -a "Firefox" "$file" || open "$file"
else
echo "No coverage/index.html file found in the current directory or its subdirectories."
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment