You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-09-16 09:26:52 +02:00
fix: check if builds.dir is a directory (#2587)
* fix: validate builds.main * fix: pr comments
This commit is contained in:
committed by
GitHub
parent
870dc146fa
commit
160d97af40
@@ -147,7 +147,10 @@ func goVersion(build config.Build) ([]byte, error) {
|
|||||||
cmd := exec.Command(build.GoBinary, "version")
|
cmd := exec.Command(build.GoBinary, "version")
|
||||||
// If the build.Dir is acessible, set the cmd dir to it in case
|
// If the build.Dir is acessible, set the cmd dir to it in case
|
||||||
// of reletive path to GoBinary
|
// 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
|
cmd.Dir = build.Dir
|
||||||
}
|
}
|
||||||
bts, err := cmd.CombinedOutput()
|
bts, err := cmd.CombinedOutput()
|
||||||
|
@@ -271,6 +271,16 @@ func TestList(t *testing.T) {
|
|||||||
require.Equal(t, []string{"linux_amd64"}, targets)
|
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) {
|
t.Run("fail", func(t *testing.T) {
|
||||||
_, err := List(config.Build{
|
_, err := List(config.Build{
|
||||||
Goos: []string{"linux"},
|
Goos: []string{"linux"},
|
||||||
|
Reference in New Issue
Block a user