Skip to content

Commit

Permalink
fix: trailing comma not allowed in ruleset
Browse files Browse the repository at this point in the history
*Issue #, if available:*
#633

*Description of changes:*

This will generate a valid TypeScript file for
`src/endpoint/ruleset.ts`.
  • Loading branch information
eduardomourar committed Nov 10, 2022
1 parent 42ca023 commit ccbb330
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private void generateEndpointRuleset() {
writer.addImport("RuleSetObject", null, "@aws-sdk/util-endpoints");
writer.openBlock(
"export const ruleSet: RuleSetObject = ",
"",
";",
() -> {
new RuleSetSerializer(
endpointRuleSetTrait.getRuleSet(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ public RuleSetSerializer(Node ruleSet, TypeScriptWriter writer) {
* Write the ruleset as a TS object.
*/
public void generate() {
traverse(ruleSet);
ObjectNode objectNode = ruleSet.expectObjectNode();
writer.openBlock(
"{",
"}",
() -> {
objectNode.getMembers().forEach((k, v) -> {
writer.writeInline("\"" + k + "\": ");
traverse(v);
});
}
);
}

private void traverse(Node node) {
Expand Down

0 comments on commit ccbb330

Please sign in to comment.