* target: rework modtime comparison logic
* fix NewestModTime, add tests for NewestModTime, OldestModTime
* added tests for Dir when target is Dir
* updates per #324
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>
* #285 add color output for mage list
* added color configuration via MAGEFILE_ENABLE_COLOR and MAGEFILE_TARGET_COLOR env vars
* use a list of specific terminals which don't support color
* Ensure MAGEFILE_VERBOSE set in compiled magefile
When using `mage -compile=foo`, ensure that passing
`-v` to the produced binary sets MAGEFILE_VERBOSE.
This is necessary for `mg.Verbose()` to return the
correct value.
This code of conduct copies the Go code of conduct and simply makes obvious that this project is also under the same code of conduct, while also adding myself to the list of people one can report to.
* Use -w as working directory flag
* Make Invocation.WorkDir works as expected when mage is used as library
* Add test for setting working directory
* Sort CLI flags in the documentation
When calling mage import, we weren't prefiltering the list of go
files, so we'd get files with build tags and test files and such.
What we want is just the normal go files for building the library.
Using go list returns us that, so use that.
The TestListMagefilesIgnoresRespectsGOOSArg test tries to list go
files with a different GOOS arg by setting GOOS to windows on Linux
systems and vice versa. This test works fine on amd64, but breaks on
arm64 because a windows/arm64 pair is not available yet and as a
result, the `go list` command underlying the `Magefiles` function
fails.
Fix this problem by keeping GOARCH as amd64 so that the go list
command does not fail.
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
* GOOS and GOARCH fixes
this fixes#169 - mage now ignores GOOS and GOARCH in the environment
when building its own binaries. The exception is if you use -goos or -goarch
when running -compile.