Skip to content

Commit

Permalink
fix: panic when adding hooks to commands
Browse files Browse the repository at this point in the history
  • Loading branch information
aisbergg committed Jul 10, 2022
1 parent 4d91775 commit 7f0b370
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,9 @@ func (c *Command) Fire(event string, data interface{}) (stop bool) {
func (c *Command) On(name string, handler HookFunc) {
Debugf("cmd: %s - register hook: <cyan>%s</>", c.Name, name)

if c.Hooks == nil {
c.Hooks = &Hooks{}
}
c.Hooks.On(name, handler)
}

Expand Down

0 comments on commit 7f0b370

Please sign in to comment.