Skip to content

Commit 69fb0a4

Browse files
authored
chore: use POSIX shell syntax in pre-commit script (#16025)
1 parent 04a0ae3 commit 69fb0a4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

web/.husky/pre-commit

+12-8
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ web_modified=false
99

1010
for file in $files
1111
do
12-
if [[ $file == "api/"* && $file == *.py ]]; then
13-
# set api_modified flag to true
14-
api_modified=true
15-
elif [[ $file == "web/"* ]]; then
16-
# set web_modified flag to true
17-
web_modified=true
18-
fi
12+
# Use POSIX compliant pattern matching
13+
case "$file" in
14+
api/*.py)
15+
# set api_modified flag to true
16+
api_modified=true
17+
;;
18+
web/*)
19+
# set web_modified flag to true
20+
web_modified=true
21+
;;
22+
esac
1923
done
2024

2125
# run linters based on the modified modules
@@ -24,7 +28,7 @@ if $api_modified; then
2428
echo "Running Ruff linter on api module"
2529

2630
# python style checks rely on `ruff` in path
27-
if ! command -v ruff &> /dev/null; then
31+
if ! command -v ruff > /dev/null 2>&1; then
2832
echo "Installing linting tools (Ruff, dotenv-linter ...) ..."
2933
poetry install -C api --only lint
3034
fi

0 commit comments

Comments
 (0)