From e0b44ecf427170e424675086ec520b910181d9e8 Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Mon, 24 Feb 2020 10:43:05 +0800 Subject: [PATCH] update verify links to fit current layout --- scripts/markdown-link-check.tpl | 6 ++-- scripts/verify-links.sh | 51 ++++++++++++++------------------- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/scripts/markdown-link-check.tpl b/scripts/markdown-link-check.tpl index de00719dd2ba..ec176be83823 100644 --- a/scripts/markdown-link-check.tpl +++ b/scripts/markdown-link-check.tpl @@ -12,9 +12,9 @@ } ], "replacementPatterns": [ - { - "pattern": "^(?!(//|/media/))", - "replacement": "/ERROR:link-must-start-with-slash-and-cannot-reference-files-in-other-version-directory:" + { + "pattern": "^(?!(/|/media/))", + "replacement": "/ERROR:link-must-start-with-slash:" }, { "comment": "prefix with repo root", diff --git a/scripts/verify-links.sh b/scripts/verify-links.sh index 28da673e4aa1..bdeac45cbc0b 100755 --- a/scripts/verify-links.sh +++ b/scripts/verify-links.sh @@ -39,35 +39,28 @@ function in_array() { } # Check all directories starting with 'v\d.*' and dev. -for d in dev $(ls -d v[0-9]*); do - if in_array $d "${IGNORE_DIRS[@]}"; then - echo "info: directory $d skipped" - continue - fi - echo "info: checking links under $d directory..." - sed \ - -e "s##$ROOT#g" \ - -e "s##$d#g" \ - scripts/markdown-link-check.tpl > $CONFIG_TMP - if [ -n "$VERBOSE" ]; then - cat $CONFIG_TMP - fi - # TODO simplify this if markdown-link-check can process multiple files together - while read -r tasks; do - for task in $tasks; do - ( - output=$(markdown-link-check --color --config "$CONFIG_TMP" "$task" -q) - if [ $? -ne 0 ]; then - printf "$output" >> $ERROR_REPORT - fi - if [ -n "$VERBOSE" ]; then - echo "$output" - fi - ) & - done - wait - done <<<"$(find "$d" -type f -name '*.md' | xargs -n 10)" -done +echo "info: checking links under $ROOT directory..." +sed \ + -e "s##$ROOT#g" \ + scripts/markdown-link-check.tpl > $CONFIG_TMP +if [ -n "$VERBOSE" ]; then + cat $CONFIG_TMP +fi +# TODO simplify this if markdown-link-check can process multiple files together +while read -r tasks; do + for task in $tasks; do + ( + output=$(markdown-link-check --color --config "$CONFIG_TMP" "$task" -q) + if [ $? -ne 0 ]; then + printf "$output" >> $ERROR_REPORT + fi + if [ -n "$VERBOSE" ]; then + echo "$output" + fi + ) & + done + wait +done <<<"$(find "." -type f -not -path './node_modules/*' -name '*.md' | xargs -n 10)" error_files=$(cat $ERROR_REPORT | grep 'FILE: ' | wc -l) error_output=$(cat $ERROR_REPORT)