Skip to content

Commit b792363

Browse files
authored
enable multi variable expansion + tests (#2495)
* enable multi var parsing + tests * formatting violation fix
1 parent 6c12b9f commit b792363

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

smithy-build/src/main/java/software/amazon/smithy/build/model/SmithyBuildUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static ObjectNode expandNode(Node node) {
6969
*/
7070
private static final class VariableExpander extends NodeVisitor.Default<Node> {
7171

72-
private static final Pattern INLINE = Pattern.compile("(?:^|[^\\\\])\\$\\{(.+)}");
72+
private static final Pattern INLINE = Pattern.compile("(?:^|[^\\\\])\\$\\{([^}]+)}");
7373
private static final Pattern ESCAPED_INLINE = Pattern.compile("\\\\\\$");
7474

7575
@Override

smithy-build/src/test/java/software/amazon/smithy/build/model/SmithyBuildConfigTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ public void expandsEnvironmentVariables() {
123123
// Did the array and string values in it expand?
124124
assertThat(transform.getArgs(),
125125
equalTo(Node.objectNode()
126-
.withMember("tags", Node.fromStrings("Hi", "compoundTagFromEnv", "${BAZ}"))));
126+
.withMember("tags",
127+
Node.fromStrings("Hi", "compoundTagFromEnv", "HiAndTagFromEnv", "${BAZ}"))));
127128
}
128129

129130
@Test

smithy-build/src/test/resources/software/amazon/smithy/build/config-with-env.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"tags": [
1010
"${FOO}",
1111
"compound${BAR}",
12+
"${FOO}And${BAR}",
1213
"\\${BAZ}"
1314
]
1415
}

0 commit comments

Comments
 (0)