1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-16 03:52:12 +02:00

feat: allow to load config from stdin (#3175)

allows to load the config from stdin, so things like:

```sh
cat .goreleaser.yml | sed 's/something/else/g' | goreleaser release -f -
```

will now work.

closes #3125

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2022-06-22 22:03:00 -03:00 committed by GitHub
parent d79484ef1d
commit 4162772819
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,10 @@ import (
)
func loadConfig(path string) (config.Project, error) {
if path == "-" {
log.Info("loading config from stdin")
return config.LoadReader(os.Stdin)
}
if path != "" {
return config.Load(path)
}

View File

@ -37,3 +37,12 @@ func TestConfigFileDoesntExist(t *testing.T) {
require.NoError(t, err)
require.Equal(t, config.Project{}, proj)
}
func TestConfigFileFromStdin(t *testing.T) {
folder := setup(t)
err := os.Remove(filepath.Join(folder, "goreleaser.yml"))
require.NoError(t, err)
proj, err := loadConfig("-")
require.NoError(t, err)
require.Equal(t, config.Project{}, proj)
}