Skip to content

Commit

Permalink
Pass MAGEFILE_GOCMD to compiled binary (#210)
Browse files Browse the repository at this point in the history
Pass the `MAGEFILE_GOCMD` environment variable into the compiled binary
when running with `-gocmd` set.

Testing Done:

- Validated that running `mage -debug -gocmd <go-runtime> <target>`
  properly sets the environment variable `MAGEFILE_GOCMD=<go-runtime>`
  into the temporary binary.
- Validated that compiled magefiles will not persist the initial
  `-gocmd` when executing - though this is still toggleable by providing
  the environment variable manually.

fixes #208
  • Loading branch information
ihgann authored and natefinch committed Mar 14, 2019
1 parent 158fd4c commit 00c8eff
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,9 @@ func RunCompiled(inv Invocation, exePath string, errlog *log.Logger) int {
if inv.Debug {
c.Env = append(c.Env, "MAGEFILE_DEBUG=1")
}
if inv.GoCmd != "" {
c.Env = append(c.Env, fmt.Sprintf("MAGEFILE_GOCMD=%s", inv.GoCmd))
}
if inv.Timeout > 0 {
c.Env = append(c.Env, fmt.Sprintf("MAGEFILE_TIMEOUT=%s", inv.Timeout.String()))
}
Expand Down

0 comments on commit 00c8eff

Please sign in to comment.