forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformat_check.sh
executable file
·32 lines (27 loc) · 1005 Bytes
/
format_check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
shopt -s extglob
warningYellow='\033[0;33m'
successGreen='\033[0;32m'
reset='\033[0m'
case "$(uname -s)" in
Darwin|Linux)
echo "Checking OCaml code formatting..."
if opam exec -- dune build @fmt; then
printf "${successGreen}✅ OCaml code formatting ok.${reset}\n"
else
printf "${warningYellow}⚠️ OCaml code formatting issues found.${reset}\n"
exit 1
fi
echo "Checking ReScript code formatting..."
files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -path "tests/syntax_*/*" ! -path "tests/gentype_tests/typescript-react-example/node_modules/*")
if ./cli/rescript format -check $files; then
printf "${successGreen}✅ ReScript code formatting ok.${reset}\n"
else
printf "${warningYellow}⚠️ ReScript code formatting issues found.${reset}\n"
exit 1
fi
;;
*)
# Does not work on Windows
echo "Code formatting checks skipped for this platform."
esac