File tree Expand file tree Collapse file tree 2 files changed +26
-11
lines changed Expand file tree Collapse file tree 2 files changed +26
-11
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ if [ $# -ne 1 ]; then
4
+ echo " Usage: bin/generator-utils/fetch_canonical_data <exercise-slug>"
5
+ exit 1
6
+ fi
7
+
8
+ # check if curl is installed
9
+ command -v curl > /dev/null 2>&1 || {
10
+ echo >&2 " curl is required but not installed. Please install it and make sure it's in your PATH."
11
+ exit 1
12
+ }
13
+
14
+ slug=$1
15
+
16
+ curlopts=(
17
+ --silent
18
+ --show-error
19
+ --fail
20
+ --location
21
+ --retry 3
22
+ --max-time 4
23
+ )
24
+ curl " ${curlopts[@]} " " https://raw.githubusercontent.com/exercism/problem-specifications/main/exercises/${slug} /canonical-data.json"
Original file line number Diff line number Diff line change @@ -14,17 +14,8 @@ use $(dash_to_underscore "$slug")::*;
14
14
15
15
EOT
16
16
17
- curlopts=(
18
- --silent
19
- --show-error
20
- --fail
21
- --location
22
- --retry 3
23
- --max-time 4
24
- )
25
- # fetch canonical_data
26
- canonical_json=$( curl " ${curlopts[@]} " " https://raw.githubusercontent.com/exercism/problem-specifications/main/exercises/${slug} /canonical-data.json" )
27
- echo " $canonical_json " >> canonical_data.json
17
+ canonical_json=$( bin/generator-utils/fetch_canonical_data " $slug " )
18
+ echo " $canonical_json " > canonical_data.json
28
19
29
20
if [ " ${canonical_json} " == " 404: Not Found" ]; then
30
21
canonical_json=$( jq --null-input ' {cases: []}' )
You can’t perform that action at this time.
0 commit comments