mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-11 14:39:28 +02:00
fix: check if builds.dir is a directory (#2587)
* fix: validate builds.main * fix: pr comments
This commit is contained in:
parent
870dc146fa
commit
160d97af40
@ -147,7 +147,10 @@ func goVersion(build config.Build) ([]byte, error) {
|
||||
cmd := exec.Command(build.GoBinary, "version")
|
||||
// If the build.Dir is acessible, set the cmd dir to it in case
|
||||
// of reletive path to GoBinary
|
||||
if _, err := os.Stat(build.Dir); err == nil {
|
||||
if fileInfo, err := os.Stat(build.Dir); err == nil {
|
||||
if !fileInfo.IsDir() {
|
||||
return nil, fmt.Errorf("invalid builds.dir property, it should be a directory: %s", build.Dir)
|
||||
}
|
||||
cmd.Dir = build.Dir
|
||||
}
|
||||
bts, err := cmd.CombinedOutput()
|
||||
|
@ -271,6 +271,16 @@ func TestList(t *testing.T) {
|
||||
require.Equal(t, []string{"linux_amd64"}, targets)
|
||||
})
|
||||
|
||||
t.Run("error with dir", func(t *testing.T) {
|
||||
_, err := List(config.Build{
|
||||
Goos: []string{"linux"},
|
||||
Goarch: []string{"amd64"},
|
||||
GoBinary: "go",
|
||||
Dir: "targets.go",
|
||||
})
|
||||
require.EqualError(t, err, "invalid builds.dir property, it should be a directory: targets.go")
|
||||
})
|
||||
|
||||
t.Run("fail", func(t *testing.T) {
|
||||
_, err := List(config.Build{
|
||||
Goos: []string{"linux"},
|
||||
|
Loading…
x
Reference in New Issue
Block a user