Skip to content

Commit

Permalink
Fix licenses.go
Browse files Browse the repository at this point in the history
  • Loading branch information
spiegel-im-spiegel committed Mar 25, 2021
1 parent ec18f1b commit ae1b4aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ builds:
- arm
- arm64
main: ./
flags:
- -trimpath
ldflags: -s -w -X github.com/spiegel-im-spiegel/depm/facade.Version=v{{ .Version }}
binary: depm

Expand Down
10 changes: 9 additions & 1 deletion modules/licenses.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"regexp"

"github.com/google/licenseclassifier"
"github.com/google/licenseclassifier/stringclassifier"
)

var (
Expand All @@ -26,7 +27,14 @@ func FindLicense(dir string) string {
if licenseRegexp.MatchString(f.Name()) {
path := filepath.Join(dir, f.Name())
if content, err := os.ReadFile(path); err == nil {
matches := classifier.MultipleMatch(string(content), true)
matches := func() stringclassifier.Matches {
defer func() {
if r := recover(); r != nil {
return
}
}()
return classifier.MultipleMatch(string(content), true)
}()
if len(matches) > 0 {
return matches[0].Name
}
Expand Down

0 comments on commit ae1b4aa

Please sign in to comment.