diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8b69f01..37a39dd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,16 +15,16 @@ Maintainers are happy to interact with humans; maintainers are not interested in ``` # Use the configlet to set things up. $ ./bin/fetch-configlet -$ ./bin/configlet create --practice-exercise $slug -a $author -d $difficulty +$ ./bin/configlet create --practice-exercise "${slug}" -a "${author}" -d "${difficulty}" # Sort `config.json`. -$ sorted=$( jq ' (.exercises.practice |= sort_by(.slug)) | .exercises.practice |= sort_by(.difficulty)' config.json ) && echo "$sorted" > config.json +$ ./bin/sort_exercises # Add the test runner. $ ./bin/update_test_runner # It's recommended you copy a .meta/template.j2 from another exercise as a starting point. # Edit the template file and use it to regenerate tests. The problem spec repo should be updated at least once. $ ./bin/generate_tests [--no-pull] # Solve the exercise and validate by running the tests. -$ ( cd exercises/practice/$slug && bash run_tests; ) +$ ( cd "exercises/practice/${slug}" && bash run_tests; ) ``` ### Error handling diff --git a/bin/sort_exercises b/bin/sort_exercises new file mode 100755 index 0000000..4a2ced1 --- /dev/null +++ b/bin/sort_exercises @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +self=$(readlink -e "$0") +bin=${self%/*} + +# shellcheck disable=SC1091 +. "${bin}/utils.bash" + +config="${REPO_ROOT}/config.json" + +sorted=$( jq ' + (.exercises.practice |= sort_by(.name | ascii_downcase)) | + .exercises.practice |= sort_by(.difficulty) +' "${config}" ) +printf '%s\n' "${sorted}" > "${config}"