Skip to content

Commit 807b84b

Browse files
author
edwmurph
committed
refactored loop through templates
1 parent 3e541ea commit 807b84b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Diff for: test/fast/Unit tests/nvm_get_node_from_pkg_json

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ die () { printf "$@" ; exit 1; }
77
# posix compliant array needed to support iterating an asterisk without it being evaluated to the list of files in the current dir
88
set -- '1.1.1' '1.1' '1' '~1.1.1' '<1.1.1' '<=1.1.1' '>1.1.1' '>=1.1.1' '1.1.1-1.1.2' '^1.1.1' '*' '=1.1.1' 'v1.1.1' 'x' 'X' '1.x.x' '1.X.X'
99

10-
PKG_JSON_TEMPLATES=$(ls package_json_templates)
11-
for TEMPLATE_NAME in $PKG_JSON_TEMPLATES; do
10+
for TEMPLATE_NAME in package_json_templates/*; do
1211
for TEST_SEMVER in "$@"; do
13-
INPUT=$(sed 's/NODE_SEMVER/'"$TEST_SEMVER"'/g' "package_json_templates/$TEMPLATE_NAME")
12+
INPUT=$(sed 's/NODE_SEMVER/'"$TEST_SEMVER"'/g' "$TEMPLATE_NAME")
1413
ACTUAL_OUTPUT=$(nvm_get_node_from_pkg_json "$INPUT")
1514
[ "$ACTUAL_OUTPUT" = "$TEST_SEMVER" ] && [ -n "$ACTUAL_OUTPUT" ] && [ -n "$INPUT" ] || die "'nvm_get_node_from_pkg_json' failed. Expected '$TEST_SEMVER' but got '$ACTUAL_OUTPUT' when given input template '$TEMPLATE_NAME':\n$INPUT"
1615
done

0 commit comments

Comments
 (0)