55export MSYS_NO_PATHCONV=1 # for Git Bash on Windows
66
77SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
8- LYCHEE_CONFIG =" $SCRIPT_DIR /../../.lychee.toml "
8+ ROOT_DIR =" $SCRIPT_DIR /../.."
99DEPENDENCIES_DOCKERFILE=" $SCRIPT_DIR /dependencies.dockerfile"
1010
11+ # Parse command line arguments
12+ RELATIVE_ONLY=false
13+ MODIFIED_FILES=" "
14+
15+ while [[ $# -gt 0 ]]; do
16+ case $1 in
17+ --relative-only)
18+ RELATIVE_ONLY=true
19+ shift
20+ ;;
21+ * )
22+ # Treat any other arguments as file paths
23+ MODIFIED_FILES=" $MODIFIED_FILES $1 "
24+ shift
25+ ;;
26+ esac
27+ done
28+
1129# Extract lychee version from dependencies.dockerfile
1230LYCHEE_VERSION=$( grep " FROM lycheeverse/lychee:" " $DEPENDENCIES_DOCKERFILE " | sed ' s/.*FROM lycheeverse\/lychee:\([^ ]*\).*/\1/' )
1331
32+ # Determine target files/directories and config file
33+ TARGET=" ."
34+ LYCHEE_CONFIG=" $SCRIPT_DIR /.lychee.toml"
35+
36+ if [[ " $RELATIVE_ONLY " == " true" ]]; then
37+ LYCHEE_CONFIG=" $SCRIPT_DIR /.lychee-relative.toml"
38+ fi
39+
40+ if [[ -n " $MODIFIED_FILES " ]]; then
41+ TARGET=" $MODIFIED_FILES "
42+ fi
43+
1444# Build the lychee command with optional GitHub token
1545CMD=" lycheeverse/lychee:$LYCHEE_VERSION --verbose --config $( basename " $LYCHEE_CONFIG " ) "
1646
@@ -19,8 +49,7 @@ if [[ -n "$GITHUB_TOKEN" ]]; then
1949 CMD=" $CMD --github-token $GITHUB_TOKEN "
2050fi
2151
22- # Add the target directory
23- CMD=" $CMD ."
52+ CMD=" $CMD $TARGET "
2453
2554# Determine if we should allocate a TTY
2655DOCKER_FLAGS=" --rm --init"
3261
3362# Run lychee with proper signal handling
3463# shellcheck disable=SC2086
35- exec docker run $DOCKER_FLAGS -v " $( dirname " $LYCHEE_CONFIG " ) " :/data -w /data $CMD
64+ exec docker run $DOCKER_FLAGS -v " $( dirname " $ROOT_DIR " ) " :/data -w /data $CMD
0 commit comments