Skip to content

Commit

Permalink
chore: change enum list failure log to a warning
Browse files Browse the repository at this point in the history
Behavior is unchanged, just how it is reported.
  • Loading branch information
Emyrk committed Dec 30, 2024
1 parent 2ffc93e commit 3805ba1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions config/mutations.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ func EnumLists(ts *guts.Typescript) {
})

for name, node := range addNodes {
if n, ok := ts.Node(name); ok {
slog.Warn(fmt.Sprintf("enum list %s cannot be added, an existing declaration with that name exists. "+
"To generate this enum list, the name collision must be resolved. ", name),
slog.String("existing", fmt.Sprintf("%s", n)))
continue
}

err := ts.SetNode(name, node)
if err != nil {
slog.Error(fmt.Sprintf("failed to add enum list %s: %v", name, err))
Expand Down
8 changes: 8 additions & 0 deletions convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ func (ts *Typescript) ReplaceNode(key string, node bindings.Node) {
}
}

func (ts *Typescript) Node(key string) (bindings.Node, bool) {
v, ok := ts.typescriptNodes[key]
if !ok {
return nil, false
}
return v.Node, true
}

func (ts *Typescript) SetNode(key string, node bindings.Node) error {
if _, ok := ts.typescriptNodes[key]; ok {
return fmt.Errorf("node %q already exists", key)
Expand Down

0 comments on commit 3805ba1

Please sign in to comment.