1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00

Allow for non-US spelling of Licence

This commit is contained in:
jspc 2016-12-30 17:31:06 +00:00
parent f5d3c6acf4
commit 0c6e7bcc77
5 changed files with 29 additions and 5 deletions

0
config/.test/LICENCE.md Normal file
View File

0
config/.test/LICENSE.md Normal file
View File

0
config/.test/README.md Normal file
View File

View File

@ -66,9 +66,12 @@ func Load(file string) (config ProjectConfig, err error) {
func fix(config ProjectConfig) ProjectConfig {
if len(config.Files) == 0 {
config.Files = []string{
"README.md",
"LICENSE.md",
config.Files = []string{}
for _, f := range []string{"README.md", "LICENCE.md", "LICENSE.md"} {
if _, err := os.Stat(f); err == nil {
config.Files = append(config.Files, f)
}
}
}
if config.Token == "" {
@ -86,6 +89,7 @@ func fix(config ProjectConfig) ProjectConfig {
if len(config.Build.Arches) == 0 {
config.Build.Arches = []string{"amd64", "386"}
}
return config
}

View File

@ -1,6 +1,7 @@
package config
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
@ -9,11 +10,30 @@ import (
func TestFixConfig(t *testing.T) {
assert := assert.New(t)
config := fix(ProjectConfig{})
assert.Equal("main.go", config.Build.Main)
assert.Contains(config.Files, "README.md")
assert.Contains(config.Files, "LICENSE.md")
assert.Contains(config.Build.Oses, "darwin")
assert.Contains(config.Build.Oses, "linux")
assert.Contains(config.Build.Arches, "386")
assert.Contains(config.Build.Arches, "amd64")
}
func TestFixConfigMissingFiles(t *testing.T) {
assert := assert.New(t)
config := fix(ProjectConfig{})
assert.NotContains(config.Files, "README.md")
assert.NotContains(config.Files, "LICENSE.md")
assert.NotContains(config.Files, "LICENCE.md")
}
func TestFixConfigNoMissingFiles(t *testing.T) {
assert := assert.New(t)
os.Chdir("./.test")
config := fix(ProjectConfig{})
assert.Contains(config.Files, "README.md")
assert.Contains(config.Files, "LICENSE.md")
assert.Contains(config.Files, "LICENCE.md")
}