File tree Expand file tree Collapse file tree 2 files changed +21
-17
lines changed Expand file tree Collapse file tree 2 files changed +21
-17
lines changed Original file line number Diff line number Diff line change @@ -5,29 +5,33 @@ set -eo pipefail
55
66repo=$( git rev-parse --show-toplevel)
77
8+ echo " Formatting exercise files..."
9+
10+ format_one_exercise () {
11+ exercise_dir=" $1 "
12+ source_file_name=" $2 "
13+
14+ cd " $exercise_dir "
15+ config_file=" $exercise_dir /.meta/config.json"
16+ if jq --exit-status ' .custom?."allowed-to-not-compile"?' " $config_file " & > /dev/null; then
17+ exit 0
18+ fi
19+ cargo fmt
20+ file_name=" .meta/$source_file_name .rs"
21+ if [ -f " $file_name " ]; then
22+ rustfmt " $file_name "
23+ fi
24+ }
25+
826# traverse either concept or practice exercise
927# directory and format Rust files
1028format_exercises () {
1129 exercises_path=" $repo /exercises/$1 "
1230 source_file_name=" $2 "
1331 for exercise_dir in " $exercises_path " /* ; do
14- (
15- cd " $exercise_dir "
16- config_file=" $exercise_dir /.meta/config.json"
17- if jq --exit-status ' .custom?."allowed-to-not-compile"?' " $config_file " ; then
18- exercise=$( basename " $exercise_dir " )
19- echo " $exercise 's stub is allowed to not compile"
20- # exit the subshell successfully to continue
21- # to the next exercise directory
22- exit 0
23- fi
24- cargo fmt
25- file_name=" .meta/$source_file_name .rs"
26- if [ -f " $file_name " ]; then
27- rustfmt " $file_name "
28- fi
29- )
32+ format_one_exercise " $exercise_dir " " $source_file_name " &
3033 done
34+ wait
3135}
3236# https://github.com/exercism/docs/blob/main/anatomy/tracks/concept-exercises.md#file-exemplar-implementation
3337format_exercises " concept" " exemplar"
Original file line number Diff line number Diff line change 2121 ./ bin/ check_exercises.sh
2222 CLIPPY=true ./ bin/ check_exercises.sh
2323 cd rust-tooling && cargo test
24- # TODO format exercises
24+ . / bin / format_exercises.sh ; git diff --exit-code
2525
2626add-exercise * args = " ":
2727 cd rust-tooling/ generate; cargo run --quiet --release -- add {{ args }}
You can’t perform that action at this time.
0 commit comments