Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update the WorkDir (-w) flag to default to the Dir (-d) value as documented #310

Merged
merged 2 commits into from
Jul 8, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update the WorkDir (-w) flag to default to the Dir (-d) value as docu…
…mented

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.
  • Loading branch information
srp committed Jun 12, 2020
commit 8c08d6ae80a13de0144c840444161156474bb012
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