-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathgenerate_practice_exercise
executable file
·46 lines (36 loc) · 1.34 KB
/
generate_practice_exercise
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
#!/usr/bin/env bash
# Exit if anything fails.
set -euo pipefail
# If argument not provided, print usage and exit
if [ -z "$1" ]; then
echo "Usage: bin/generate_practice_exercise <exercise-slug>"
exit 1
fi
if ! [ -x "$(command -v jq)" ]; then
echo "jq is required. Please install jq and make sure it is on the $PATH: https://stedolan.github.io/jq/download/" >&2
exit 1
fi
if ! [ -x "$(command -v emacs)" ]; then
echo "Emacs is required. Please install Emacs and make sure it is on the $PATH: https://www.gnu.org/software/emacs/download.html" >&2
exit 1
fi
SLUG="$1"
exercise_dir="exercises/practice/${SLUG}"
download() {
file="$1"
url="$2"
curl --silent --show-error --fail --retry 3 --max-time 3 \
--output "$file" "$url"
}
# build configlet
echo "Fetching latest version of configlet..."
./bin/fetch-configlet
# Preparing config.json
echo "Adding instructions and configuration files..."
./bin/configlet create --practice-exercise "$SLUG"
pushd tools
emacs -batch -l install-packages.el -l practice-exercise-generator.el --eval "(exercism/generate-practice-exercise \"$SLUG\")"
popd
echo "All stub files were created. After implementing the solution, tests and configuration, please run:"
echo " ./bin/configlet sync --update --tests --exercise ${SLUG}"
echo " ./bin/configlet fmt --update --yes --exercise ${SLUG}"