Skip to content

Commit 1514d36

Browse files
committed
added exercise name fetch
1 parent 3043fd2 commit 1514d36

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

bin/generate_practice_exercise.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@ SLUG="$1"
1515
echo "Fetching latest version of configlet..."
1616
./bin/fetch-configlet
1717

18+
# Fetch the exercise name from problem-specifications
19+
echo "Fetching exercise name for $SLUG..."
20+
NAME=$(curl --silent --location "https://raw.githubusercontent.com/exercism/problem-specifications/main/exercises/${SLUG}/metadata.toml" | sed -n 's/^title = "\(.*\)"/\1/p')
21+
if [ -z "$NAME" ]; then
22+
NAME="TODO"
23+
fi
24+
1825
# Preparing config.json
1926
echo "Adding instructions and configuration files..."
2027
UUID=$(bin/configlet uuid)
21-
jq --arg slug "$SLUG" --arg uuid "$UUID" \
22-
'.exercises.practice += [{slug: $slug, name: "TODO", uuid: $uuid, practices: [], prerequisites: [], difficulty: 5}]' \
28+
jq --arg slug "$SLUG" --arg uuid "$UUID" --arg name "$NAME" \
29+
'.exercises.practice += [{slug: $slug, name: $name, uuid: $uuid, practices: [], prerequisites: [], difficulty: 5}]' \
2330
config.json > config.json.tmp
2431
mv config.json.tmp config.json
2532

0 commit comments

Comments
 (0)