Skip to content

Commit

Permalink
update the WorkDir (-w) flag to default to the Dir (-d) value as docu…
Browse files Browse the repository at this point in the history
…mented (magefile#310)

The code settings up the command-line switch was passing `inv.Dir` as the
default value, which at the time of the call is always `"."`. This means
that the later code that sets `inv.WorkDir = inv.Dir` won't run because
`inv.WorkDir` is not the empty string.

The command line -help documentation reads:

      -w <string>
            working directory where magefiles will run (default -d value)

But given the above, this is not the observed behavior.

Now `inv.WorkDir` is defaulted to the empty string, and the code works
as expected.

Co-authored-by: Nate Finch <nate.finch@gmail.com>
  • Loading branch information
srp and natefinch authored Jul 8, 2020
1 parent 9a10961 commit 707b7bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func Parse(stderr, stdout io.Writer, args []string) (inv Invocation, cmd Command
fs.DurationVar(&inv.Timeout, "t", 0, "timeout in duration parsable format (e.g. 5m30s)")
fs.BoolVar(&inv.Keep, "keep", false, "keep intermediate mage files around after running")
fs.StringVar(&inv.Dir, "d", ".", "directory to read magefiles from")
fs.StringVar(&inv.WorkDir, "w", inv.Dir, "working directory where magefiles will run")
fs.StringVar(&inv.WorkDir, "w", "", "working directory where magefiles will run")
fs.StringVar(&inv.GoCmd, "gocmd", mg.GoCmd(), "use the given go binary to compile the output")
fs.StringVar(&inv.GOOS, "goos", "", "set GOOS for binary produced with -compile")
fs.StringVar(&inv.GOARCH, "goarch", "", "set GOARCH for binary produced with -compile")
Expand Down

0 comments on commit 707b7bd

Please sign in to comment.