Skip to content

Commit

Permalink
Change handling of ExtraPath (nektos#406)
Browse files Browse the repository at this point in the history
To make the handling of ExtraPath portable append it to the front of the
PATH when it exists, instead of always changing the script.
  • Loading branch information
winksaville authored Nov 2, 2020
1 parent 92067eb commit 8204ef4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/runner/step_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ func (sc *StepContext) setupEnv() common.Executor {
env = mergeMaps(rc.GetEnv(), step.GetEnv())
}

if (rc.ExtraPath != nil) && (len(rc.ExtraPath) > 0) {
s := append(rc.ExtraPath, os.Getenv("PATH"))
env["PATH"] = strings.Join(s, string(os.PathSeparator))
}

for k, v := range env {
env[k] = rc.ExprEval.Interpolate(v)
}
Expand All @@ -106,11 +111,7 @@ func (sc *StepContext) setupShellCommand() common.Executor {
step := sc.Step
return func(ctx context.Context) error {
var script strings.Builder

_, err := script.WriteString(fmt.Sprintf("PATH=\"%s:${PATH}\"\n", strings.Join(rc.ExtraPath, ":")))
if err != nil {
return err
}
var err error

if step.WorkingDirectory == "" {
step.WorkingDirectory = rc.Run.Job().Defaults.Run.WorkingDirectory
Expand Down

0 comments on commit 8204ef4

Please sign in to comment.