aboutsummaryrefslogtreecommitdiff
path: root/spdxconv.go
diff options
context:
space:
mode:
Diffstat (limited to 'spdxconv.go')
-rw-r--r--spdxconv.go24
1 files changed, 16 insertions, 8 deletions
diff --git a/spdxconv.go b/spdxconv.go
index be13a2c..d56b283 100644
--- a/spdxconv.go
+++ b/spdxconv.go
@@ -6,6 +6,7 @@ package spdxconv
import (
"bytes"
"fmt"
+ "io/fs"
"log"
"maps"
"os"
@@ -264,10 +265,14 @@ func (conv *SPDXConv) scanFile(dir, name string) (listFile []string, err error)
// A common ignore file or directory name likes ".git", "node_modules", and
// "vendor"; also will be excluded.
func (conv *SPDXConv) scanDir(listDir []string) (listFile []string, err error) {
+ var logp = `scanDir`
var commonIgnore = map[string]struct{}{
`.git`: struct{}{},
- `node_modules`: struct{}{},
ConfigFile: struct{}{},
+ `COPYING`: struct{}{},
+ `LICENSE`: struct{}{},
+ `LICENSES`: struct{}{}, // Directory contains licenses.
+ `node_modules`: struct{}{},
ReportFile: struct{}{},
`vendor`: struct{}{},
}
@@ -282,7 +287,7 @@ func (conv *SPDXConv) scanDir(listDir []string) (listFile []string, err error) {
listde, err = os.ReadDir(dir)
if err != nil {
- return nil, err
+ return nil, fmt.Errorf(`%s: %w`, logp, err)
}
var listFileLicense = make(map[string]struct{})
@@ -293,19 +298,22 @@ func (conv *SPDXConv) scanDir(listDir []string) (listFile []string, err error) {
listFileLicense[name] = struct{}{}
continue
}
- if conv.scm.IsIgnored(name) {
- continue
- }
_, ok = commonIgnore[name]
if ok {
continue
}
- var fullpath = filepath.Join(dir, name)
+ if de.Type()&fs.ModeSymlink != 0 {
+ continue
+ }
+ var relpath = filepath.Join(dir, name)
+ if conv.scm.IsIgnored(relpath) {
+ continue
+ }
if de.IsDir() {
- listDir = append(listDir, fullpath)
+ listDir = append(listDir, relpath)
continue
}
- listNamePath[name] = fullpath
+ listNamePath[name] = relpath
}
// Remove the file that have the spdx .license file.
for name := range listFileLicense {