Skip to content

Commit 97d9edd

Browse files
committed
Fix local variables
1 parent a4c275b commit 97d9edd

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

bin/generator-utils/prompts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ validate_difficulty_input() {
2525
}
2626

2727
get_author_handle() {
28-
default_author_handle="$(git config user.name)"
2928
local default_author_handle
29+
default_author_handle="$(git config user.name)"
3030

3131
if [ -z "$default_author_handle" ]; then
3232
read -rp "Hey! Couldn't find your Github handle. Add it now or skip with enter and add it later in the .meta.config.json file: " author_handle

bin/generator-utils/templates.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ EOT
4040
message "info" "This exercise doesn't have canonical data."
4141
message "success" "Stub file for tests has been created!"
4242
else
43-
canonical_json=$(cat canonical_data.json)
4443
local canonical_json
44+
canonical_json=$(cat canonical_data.json)
4545

4646
# sometimes canonical data has multiple levels with multiple `cases` arrays.
4747
#(see kindergarten-garden https://github.com/exercism/problem-specifications/blob/main/exercises/kindergarten-garden/canonical-data.json)
4848
# so let's flatten it
49-
cases=$(echo "$canonical_json" | jq '[ .. | objects | with_entries(select(.key | IN("uuid", "description", "input", "expected"))) | select(. != {}) | select(has("uuid")) ]')
5049
local cases
51-
fn_name=$(echo "$canonical_json" | jq -r 'first(.. | .property? // empty)')
50+
cases=$(echo "$canonical_json" | jq '[ .. | objects | with_entries(select(.key | IN("uuid", "description", "input", "expected"))) | select(. != {}) | select(has("uuid")) ]')
5251
local fn_name
52+
fn_name=$(echo "$canonical_json" | jq -r 'first(.. | .property? // empty)')
5353

5454
first_iteration=true
5555
# loop through each object
@@ -82,6 +82,7 @@ function create_lib_rs_template() {
8282
local exercise_dir=$1
8383
local slug=$2
8484
local has_canonical_data=$3
85+
local fn_name
8586
fn_name=$(create_fn_name "$slug" "$has_canonical_data")
8687
cat <<EOT >"${exercise_dir}/src/lib.rs"
8788
pub fn ${fn_name}() {
@@ -111,8 +112,8 @@ function create_example_rs_template() {
111112
local slug=$2
112113
local has_canonical_data=$3
113114

114-
fn_name=$(create_fn_name "$slug" "$has_canonical_data")
115115
local fn_name
116+
fn_name=$(create_fn_name "$slug" "$has_canonical_data")
116117

117118
mkdir "${exercise_dir}/.meta"
118119
cat <<EOT >"${exercise_dir}/.meta/example.rs"

bin/generator-utils/utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ function message() {
1616
"done")
1717
echo
1818
# Create a dashed-line as wide as the screen
19-
cols=$(tput cols)
2019
local cols
20+
cols=$(tput cols)
2121
printf "%*s\n" "$cols" "" | tr " " "-"
2222
echo
2323
printf "${bold_green}%s${reset_color}\n" "[done]: $message"

0 commit comments

Comments
 (0)