sourcegraph/dev/eslint-report-test.sh
Greg Magolan b398952eca
Revert "revert "bazel: improve ESLint rule" (#52853)" (#52878)
- Revert "revert "bazel: improve ESLint rule" (#52853)"
- bazel: fix eslint custom rule so js_binary runfiles are included as
tool inputs to ctx.actions.run_shell

## Test plan

Tested locally that fix commit resolves the
```
FATAL: aspect_rules_js[js_test]: RUNFILES environment variable is not set
```
flaky issue that prompted the revert
2023-06-04 19:06:39 -07:00

29 lines
692 B
Bash
Executable File

#!/usr/bin/env bash
# The relative path to the eslint report
ESLINT_REPORT="$1"
# Ensure that the eslint report exists
if [ ! -f "$ESLINT_REPORT" ]; then
echo "${ESLINT_REPORT} does not exist."
exit 1
fi
# Check if the eslint report is empty
if [ -s "$ESLINT_REPORT" ]; then
# Get the absolute path to the eslint report.
absolute_report_path="$(realpath "$ESLINT_REPORT")"
# Remove everything before "__main__/" from the absolute path to the report.
workspace_report_path="${absolute_report_path#*__main__/}"
# Print the relative report path.
echo "ESLint report: $workspace_report_path"
cat "$ESLINT_REPORT"
exit 1
else
echo "No ESLint issues found."
exit 0
fi