forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat_check.sh
More file actions
executable file
·47 lines (41 loc) · 1.66 KB
/
Copy pathformat_check.sh
File metadata and controls
executable file
·47 lines (41 loc) · 1.66 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/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 packages tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -name "generated_mocha_test.res" ! -path "tests/build_tests/super_errors/fixtures/break_keyword_binding.res" ! -path "tests/build_tests/super_errors_multi/fixtures/Iface_not_compiled/*" ! -path "tests/syntax_tests*" ! -path "tests/analysis_tests/tests*" ! -path "*/node_modules/*")
if ./cli/rescript.js format --check $files; then
printf "${successGreen}✅ ReScript code formatting ok.${reset}\n"
else
printf "${warningYellow}⚠️ ReScript code formatting issues found. Run 'make format' to fix.${reset}\n"
exit 1
fi
;;
*)
# Does not work on Windows
echo "Code formatting checks skipped for this platform."
esac
echo "Checking JS code formatting..."
if yarn check; then
printf "${successGreen}✅ JS code formatting ok.${reset}\n"
else
printf "${warningYellow}⚠️ JS code formatting issues found.${reset}\n"
exit 1
fi
echo "Checking Rust code formatting..."
if cargo fmt --check --manifest-path rewatch/Cargo.toml; then
printf "${successGreen}✅ Rust code formatting ok.${reset}\n"
else
printf "${warningYellow}⚠️ Rust code formatting issues found.${reset}\n"
exit 1
fi