Add tests/max-length

pull/129/head
Igor Chubin 4 years ago
parent 592eef7e29
commit 3f5b5264ea

@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Check comment lines (lines starting with #) in cheat sheets
# and list files with such lines, and return exit code 1.
# Return exit code 0, if no cheat sheets with long lines found
MAX_STRING_LENGTH=80
MY_DIR=$(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")
SHEETS_DIR="$MY_DIR/sheets"
long_lines_sheets=$(
cd "$SHEETS_DIR" &&
grep -rPl "#.{${MAX_STRING_LENGTH}}"
)
if [[ $(printf "%s\n" "$long_lines_sheets" | wc -l) -gt 1 ]]; then
echo "Files with long (> 80) lines:"
echo
printf "%s\n" "$long_lines_sheets"
exit 1
fi
Loading…
Cancel
Save