lint/lib/functions/output.sh
Marco Ferrari ef57e132e1
fix: avoid duplicated content in summary (#5939)
- Remove the previous summary file is present to avoid showing stale
  contents from old summaries.
- Extract the logic to write summary heading and lines to dedicated
  functions in output.sh to make it easier adding new formats in the
  future.
2024-07-30 08:35:14 +02:00

40 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
WriteSummaryHeader() {
local SUPER_LINTER_SUMMARY_OUTPUT_PATH="${1}"
{
echo "# Super-linter summary"
echo ""
echo "| Language | Validation result |"
echo "| -----------------------|-------------------|"
} >>"${SUPER_LINTER_SUMMARY_OUTPUT_PATH}"
}
WriteSummaryLineSuccess() {
local SUPER_LINTER_SUMMARY_OUTPUT_PATH="${1}"
local LANGUAGE_NAME="${2}"
echo "| ${LANGUAGE_NAME} | Pass ✅ |" >>"${SUPER_LINTER_SUMMARY_OUTPUT_PATH}"
}
WriteSummaryLineFailure() {
local SUPER_LINTER_SUMMARY_OUTPUT_PATH="${1}"
local LANGUAGE_NAME="${2}"
echo "| ${LANGUAGE_NAME} | Fail ❌ |" >>"${SUPER_LINTER_SUMMARY_OUTPUT_PATH}"
}
WriteSummaryFooterSuccess() {
local SUPER_LINTER_SUMMARY_OUTPUT_PATH="${1}"
{
echo ""
echo "All files and directories linted successfully"
} >>"${SUPER_LINTER_SUMMARY_OUTPUT_PATH}"
}
WriteSummaryFooterFailure() {
local SUPER_LINTER_SUMMARY_OUTPUT_PATH="${1}"
{
echo ""
echo "Super-linter detected linting errors"
} >>"${SUPER_LINTER_SUMMARY_OUTPUT_PATH}"
}