Skip to content

Commit

Permalink
refactor: use event type constants correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaschain committed Dec 3, 2023
1 parent 59b0b02 commit f236d13
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/command_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func replaceTokens(text string, event *ChangeEvent) string {
text = strings.ReplaceAll(text, "{type}", event.Type)
text = strings.ReplaceAll(text, "{type}", event.Type.String())
return strings.ReplaceAll(text, "{file}", event.FileName)
}

Expand Down
20 changes: 16 additions & 4 deletions core/event_types/event_types.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
package event_types

type EventType = string
type EventType string

var (
Create EventType = "CREATE"
Write = "WRITE"
Remove = "REMOVE"
Rename = "RENAME"
Write EventType = "WRITE"
Remove EventType = "REMOVE"
Rename EventType = "RENAME"
)

func (e EventType) IsValid() bool {
switch e {
case Create, Write, Remove, Rename:
return true
}
return false
}

func (e EventType) String() string {
return string(e)
}

0 comments on commit f236d13

Please sign in to comment.