Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 8f6b25e

Browse files
Sauyon Leesmowton
authored andcommitted
autobuilder: Use -mod=mod for vendor directories wihtout modules.txt
1 parent 70d425d commit 8f6b25e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

extractor/cli/go-autobuilder/go-autobuilder.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ func main() {
244244
// skip the dependency installation step and run the extractor with `-mod=vendor`
245245
if util.FileExists("vendor/modules.txt") {
246246
modMode = ModVendor
247+
} else if util.DirExists("vendor") {
248+
modMode = modModIfSupported()
247249
}
250+
248251
if modMode == ModVendor {
249252
// fix go vendor issues with go versions >= 1.14 when no go version is specified in the go.mod
250253
// if this is the case, and dependencies were vendored with an old go version (and therefore

extractor/util/util.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,12 @@ func FileExists(filename string) bool {
9191
}
9292
return err == nil && !info.IsDir()
9393
}
94+
95+
// DirExists tests whether `filename` exists and is a directory.
96+
func DirExists(filename string) bool {
97+
info, err := os.Stat(filename)
98+
if err != nil && !os.IsNotExist(err) {
99+
log.Printf("Unable to stat %s: %s\n", filename, err.Error())
100+
}
101+
return err == nil && info.IsDir()
102+
}

0 commit comments

Comments
 (0)