Skip to content

Commit

Permalink
Merge pull request #46 from gaurav-nelson/revert-quiet
Browse files Browse the repository at this point in the history
Revert "Cleanup output for -q option"
  • Loading branch information
gaurav-nelson committed Jun 6, 2020
2 parents 820c058 + 27cd4bd commit 1a12c4c
Showing 1 changed file with 15 additions and 46 deletions.
61 changes: 15 additions & 46 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,54 +28,23 @@ echo -e "${BLUE}CHECK_MODIFIED_FILES: $6${NC}"
echo -e "${BLUE}FILE_EXTENSION: $8${NC}"

check_errors () {
if [ -e error.txt ] ; then
if [ "$USE_QUIET_MODE" = "yes" ]; then
# Even with -q option markdown-link-check shows all processed files
# the following logic cleans the output to only show files with errors.
touch output.txt
PREVIOUS_LINE=""
ERROR_FILE="error.txt"
while IFS= read -r LINE
do
if [[ $LINE = *"FILE"* ]]; then
PREVIOUS_LINE=$LINE
if [[ $(tail -1 output.txt) != *FILE* ]]; then
echo -e "\n" >> output.txt
echo "$LINE" >> output.txt
fi
elif [[ $LINE = *"[鉁朷"* ]] && [[ $PREVIOUS_LINE = *"FILE"* ]]; then
echo "$LINE" >> output.txt
else
PREVIOUS_LINE=""
fi

done < "$ERROR_FILE"
fi

if grep -q "ERROR:" error.txt; then
echo -e "${YELLOW}=========================> MARKDOWN LINK CHECK <=========================${NC}"
if [ "$USE_QUIET_MODE" = "yes" ]; then
if [[ $(tail -1 output.txt) = *FILE* ]]; then
sed '$d' output.txt
else
cat output.txt
fi
else
cat error.txt
fi
printf "\n"
echo -e "${YELLOW}=========================================================================${NC}"
exit 113
else
echo -e "${YELLOW}=========================> MARKDOWN LINK CHECK <=========================${NC}"
printf "\n"
echo -e "${GREEN}[鉁擼 All links are good!${NC}"
printf "\n"
echo -e "${YELLOW}=========================================================================${NC}"
fi
if [ -e error.txt ] ; then
if grep -q "ERROR:" error.txt; then
echo -e "${YELLOW}=========================> MARKDOWN LINK CHECK <=========================${NC}"
cat error.txt
printf "\n"
echo -e "${YELLOW}=========================================================================${NC}"
exit 113
else
echo -e "${GREEN}All good!${NC}"
echo -e "${YELLOW}=========================> MARKDOWN LINK CHECK <=========================${NC}"
printf "\n"
echo -e "${GREEN}[鉁擼 All links are good!${NC}"
printf "\n"
echo -e "${YELLOW}=========================================================================${NC}"
fi
else
echo -e "${GREEN}All good!${NC}"
fi
}

if [ "$CHECK_MODIFIED_FILES" = "yes" ]; then
Expand Down

0 comments on commit 1a12c4c

Please sign in to comment.