Skip to content

Commit

Permalink
Merge pull request #258 from lets-cli/issue-256
Browse files Browse the repository at this point in the history
fix #256 - ensure init does not get called twice
  • Loading branch information
kindermax authored Jun 25, 2024
2 parents 963ee29 + 622aa54 commit 0edc10b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (e *ExecuteError) ExitCode() int {
type Executor struct {
cfg *config.Config
out io.Writer
initCalled bool
}

func NewExecutor(cfg *config.Config, out io.Writer) *Executor {
Expand Down Expand Up @@ -72,7 +73,8 @@ func ChildExecutorCtx(ctx *Context, command *config.Command) *Context {
// Execute executes command and it depends recursively
// Command can be executed in parallel.
func (e *Executor) Execute(ctx *Context) error {
if e.cfg.Init != "" {
if e.cfg.Init != "" && !e.initCalled {
e.initCalled = true
if err := e.runCmd(ctx, &config.Cmd{Script: e.cfg.Init}); err != nil {
return err
}
Expand Down Expand Up @@ -208,7 +210,7 @@ func (e *Executor) setupEnv(osCmd *exec.Cmd, command *config.Command, shell stri
"LETS_COMMAND_WORK_DIR": osCmd.Dir,
"LETS_CONFIG": filepath.Base(e.cfg.FilePath),
"LETS_CONFIG_DIR": filepath.Dir(e.cfg.FilePath),
"LETS_SHELL": shell,
"LETS_SHELL": shell,
}

checksumEnvMap := getChecksumEnvMap(command.ChecksumMap)
Expand Down

0 comments on commit 0edc10b

Please sign in to comment.