-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b8ce7c
commit b20d3fe
Showing
4 changed files
with
35 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,9 @@ RED='\033[0;31m' | |
npm i -g [email protected] | ||
|
||
declare -a FIND_CALL | ||
declare -a COMMAND_DIRS COMMAND_FILES | ||
declare -a COMMAND_DIRS | ||
declare -a COMMAND_FILES | ||
declare -a COMMAND_EXCLUDE | ||
|
||
USE_QUIET_MODE="$1" | ||
USE_VERBOSE_MODE="$2" | ||
|
@@ -27,6 +28,7 @@ else | |
FILE_EXTENSION="$8" | ||
fi | ||
FILE_PATH="$9" | ||
EXCLUDE=$(echo ${10}) | ||
|
||
if [ -f "$CONFIG_FILE" ]; then | ||
echo -e "${BLUE}Using markdown-link-check configuration file: ${YELLOW}$CONFIG_FILE${NC}" | ||
|
@@ -38,6 +40,7 @@ fi | |
|
||
FOLDERS="" | ||
FILES="" | ||
EXCLUDED_FILES_DIRS="" | ||
|
||
echo -e "${BLUE}USE_QUIET_MODE: $1${NC}" | ||
echo -e "${BLUE}USE_VERBOSE_MODE: $2${NC}" | ||
|
@@ -46,6 +49,7 @@ echo -e "${BLUE}MAX_DEPTH: $5${NC}" | |
echo -e "${BLUE}CHECK_MODIFIED_FILES: $6${NC}" | ||
echo -e "${BLUE}FILE_EXTENSION: $8${NC}" | ||
echo -e "${BLUE}FILE_PATH: $9${NC}" | ||
echo -e "${BLUE}EXCLUDE: ${10}${NC}" | ||
|
||
handle_dirs () { | ||
|
||
|
@@ -55,6 +59,7 @@ handle_dirs () { | |
do | ||
if [ ! -d "${DIRLIST[index]}" ]; then | ||
echo -e "${RED}ERROR [✖] Can't find the directory: ${YELLOW}${DIRLIST[index]}${NC}" | ||
echo -e "${RED}Check folder-path variable!" | ||
exit 2 | ||
fi | ||
COMMAND_DIRS+=("${DIRLIST[index]}") | ||
|
@@ -71,6 +76,7 @@ handle_files () { | |
do | ||
if [ ! -f "${FILELIST[index]}" ]; then | ||
echo -e "${RED}ERROR [✖] Can't find the file: ${YELLOW}${FILELIST[index]}${NC}" | ||
echo -e "${RED}Check file-path variable!" | ||
exit 2 | ||
fi | ||
if [ $index == 0 ]; then | ||
|
@@ -83,6 +89,16 @@ handle_files () { | |
|
||
} | ||
|
||
handle_excluded () { | ||
|
||
if [ -n "${EXCLUDE}" ]; then | ||
EXCLUDED_FILES_DIRS=$(echo $EXCLUDE | sed -r 's/[,]+/ -E/g') | ||
else | ||
EXCLUDED_FILES_DIRS=".git" | ||
fi | ||
|
||
} | ||
|
||
check_errors () { | ||
|
||
if [ -e error.txt ] ; then | ||
|
@@ -125,9 +141,9 @@ check_additional_files () { | |
|
||
if [ -n "$FILES" ]; then | ||
if [ "$MAX_DEPTH" -ne -1 ]; then | ||
FIND_CALL=('fd' '--type' 'f' '-p' '('"${FILES// /}"')' '--max-depth' "${MAX_DEPTH}" '.' '--exec' 'markdown-link-check') | ||
FIND_CALL=('fd' '--type' 'f' '-p' '('"${FILES// /}"')' '--max-depth' "${MAX_DEPTH}" '.' '-E' "${EXCLUDED_FILES_DIRS}" '--exec' 'markdown-link-check') | ||
else | ||
FIND_CALL=('fd' '--type' 'f' '-p' '('"${FILES// /}"')' '.' '--exec' 'markdown-link-check') | ||
FIND_CALL=('fd' '--type' 'f' '-p' '('"${FILES// /}"')' '.' '-E' "${EXCLUDED_FILES_DIRS}" '--exec' 'markdown-link-check') | ||
fi | ||
|
||
add_options | ||
|
@@ -142,6 +158,8 @@ check_additional_files () { | |
|
||
} | ||
|
||
handle_excluded | ||
|
||
if [ -z "$8" ]; then | ||
FOLDERS="." | ||
else | ||
|
@@ -176,15 +194,15 @@ if [ "$CHECK_MODIFIED_FILES" = "yes" ]; then | |
done | ||
|
||
check_additional_files | ||
|
||
check_errors | ||
|
||
else | ||
|
||
if [ "$5" -ne -1 ]; then | ||
FIND_CALL=('fd' '.' ${FOLDERS} '-e' "${FILE_EXTENSION}" '--max-depth' "${MAX_DEPTH}" '--exec' 'markdown-link-check') | ||
FIND_CALL=('fd' '.' ${FOLDERS} '-e' "${FILE_EXTENSION}" '--max-depth' "${MAX_DEPTH}" '-E' ${EXCLUDED_FILES_DIRS} '--exec' 'markdown-link-check') | ||
else | ||
FIND_CALL=('fd' '.' ${FOLDERS} '-e' "${FILE_EXTENSION}" '--exec' 'markdown-link-check') | ||
FIND_CALL=('fd' '.' ${FOLDERS} '-e' "${FILE_EXTENSION}" '-E' ${EXCLUDED_FILES_DIRS} '--exec' 'markdown-link-check') | ||
fi | ||
|
||
add_options | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters