Skip to content

Commit

Permalink
Add check if action doesn't support hollow command
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Oct 9, 2023
1 parent 5567b6e commit a158221
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cli/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,17 @@ func runAction(a *recipe.Action, cmdEnv *CommandEnv) error {
time.Sleep(25 * time.Millisecond)
}

switch a.Name {
case recipe.ACTION_EXIT, recipe.ACTION_EXPECT, recipe.ACTION_PRINT,
recipe.ACTION_WAIT_OUTPUT, recipe.ACTION_OUTPUT_CONTAINS,
recipe.ACTION_OUTPUT_EMPTY, recipe.ACTION_OUTPUT_MATCH,
recipe.ACTION_OUTPUT_TRIM, recipe.ACTION_SIGNAL:

if cmdEnv == nil {
return fmt.Errorf("Action %q doesn't support hollow commands (without executing binary)", a.Name)
}
}

switch a.Name {
case recipe.ACTION_EXIT:
return action.Exit(a, cmdEnv.cmd)
Expand Down Expand Up @@ -419,7 +430,7 @@ func runAction(a *recipe.Action, cmdEnv *CommandEnv) error {
handler, ok := handlers[a.Name]

if !ok {
return fmt.Errorf("Can't find handler for action %s", a.Name)
return fmt.Errorf("Can't find handler for action %q", a.Name)
}

return handler(a)
Expand Down

0 comments on commit a158221

Please sign in to comment.