@@ -30,61 +30,27 @@ TOP_DIR=$(git rev-parse --show-toplevel)
3030# Add license header to all files that don't already have it.
3131" ${TOP_DIR} /scripts/add_license"
3232
33- # Format all TOML files.
34- " ${TOP_DIR} /scripts/format_toml_files"
35- if [[ $? -ne 0 ]]; then
36- exit 1
37- fi
38-
39- # Format all Python code and organize imports.
40- uv run --directory " ${TOP_DIR} /python" ruff check --select I --fix --preview --unsafe-fixes .
41- uv run --directory " ${TOP_DIR} /python" ruff format --preview .
42- if [[ $? -ne 0 ]]; then
43- exit 1
44- fi
45-
46- # Modernize and format all Go code.
47- go mod -C " ${TOP_DIR} /go" tidy -go=" ${GO_VERSION} "
48- go fmt -C " ${TOP_DIR} /go" ./...
49- if [[ $? -ne 0 ]]; then
50- exit 1
51- fi
52-
53- # Format all TypeScript code.
54- pushd " ${TOP_DIR} "
55- pnpm run format
56- if [[ $? -ne 0 ]]; then
57- exit 1
58- fi
59- popd
60-
61- # Format handlebarrz
62- pushd " ${TOP_DIR} /python/handlebarrz"
63- cargo fmt --all
64- if [[ $? -ne 0 ]]; then
65- exit 1
66- fi
67- popd
68-
69- # Format all rust code
70- pushd " ${TOP_DIR} "
71- cargo fmt --all
72- if [[ $? -ne 0 ]]; then
73- exit 1
74- fi
75- popd
76-
77- # Format all Java code.
78- pushd " ${TOP_DIR} "
79- " ${TOP_DIR} /scripts/format_java_files"
80- if [[ $? -ne 0 ]]; then
81- exit 1
82- fi
83- popd
84-
85- # Format all build files.
86- if ! command -v " buildifier" > /dev/null 2>&1 ; then
87- echo " Buildifier not found. Installing via go install..."
88- go install github.com/bazelbuild/buildtools/buildifier@latest
89- fi
90- buildifier -r " ${TOP_DIR} "
33+ if command -v rust-parallel > /dev/null 2>&1 ; then
34+ echo " Using rust-parallel to format files in parallel"
35+ printf " %s\n" \
36+ " ${TOP_DIR} /scripts/format_go_files" \
37+ " ${TOP_DIR} /scripts/format_java_files" \
38+ " ${TOP_DIR} /scripts/format_rust_files" \
39+ " ${TOP_DIR} /scripts/format_python_files" \
40+ " ${TOP_DIR} /scripts/format_handlebarrz_files" \
41+ " ${TOP_DIR} /scripts/format_toml_files" \
42+ " ${TOP_DIR} /scripts/format_ts_files" \
43+ | rust-parallel -s --exit-on-error || exit 1
44+ else
45+ echo " rust-parallel was not detected; not performing formatting in parallel"
46+ " ${TOP_DIR} /scripts/format_go_files" || exit 1
47+ " ${TOP_DIR} /scripts/format_java_files" || exit 1
48+ " ${TOP_DIR} /scripts/format_python_files" || exit 1
49+ " ${TOP_DIR} /scripts/format_handlebarrz_files" || exit 1
50+ " ${TOP_DIR} /scripts/format_rust_files" || exit 1
51+ " ${TOP_DIR} /scripts/format_toml_files" || exit 1
52+ " ${TOP_DIR} /scripts/format_ts_files" || exit 1
53+ fi
54+
55+ # Do this after all of the above have completed.
56+ " ${TOP_DIR} /scripts/format_build_files" || exit 1
0 commit comments