#!/bin/bash shopt -s extglob warningYellow='\033[0;33m' successGreen='\033[0;32m' reset='\033[0m' 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..." # xargs passes the files in batches that fit the platform's command-line # length limit, which is only 32K characters on Windows. if 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/tools_tests/*/NoMigration.res*" ! -path "tests/build_tests/super_errors_multi/fixtures/Iface_not_compiled/*" ! -path "tests/syntax_tests*" ! -path "tests/analysis_tests/tests*" ! -path "*/node_modules/*" -print0 \ | xargs -0 node ./cli/rescript.js format --check; 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 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