mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
Go: Call go mod vendor to synchronise vendor directory when it exists
This commit is contained in:
@@ -480,9 +480,17 @@ func installDependencies(workspace project.GoWorkspace) {
|
||||
|
||||
// get dependencies for all modules
|
||||
for _, module := range workspace.Modules {
|
||||
path := filepath.Dir(module.Path)
|
||||
|
||||
if util.DirExists(filepath.Join(path, "vendor")) {
|
||||
vendor := toolchain.VendorModule(path)
|
||||
log.Printf("Synchronizing vendor file using `go mod vendor` in %s.\n", path)
|
||||
util.RunCmd(vendor)
|
||||
}
|
||||
|
||||
install = exec.Command("go", "get", "-v", "./...")
|
||||
install.Dir = filepath.Dir(module.Path)
|
||||
log.Printf("Installing dependencies using `go get -v ./...` in `%s`.\n", filepath.Dir(module.Path))
|
||||
install.Dir = path
|
||||
log.Printf("Installing dependencies using `go get -v ./...` in `%s`.\n", path)
|
||||
util.RunCmd(install)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,3 +85,10 @@ func InitModule(path string) *exec.Cmd {
|
||||
modInit.Dir = path
|
||||
return modInit
|
||||
}
|
||||
|
||||
// Constructs a command to run `go mod vendor` in the directory given by `path`.
|
||||
func VendorModule(path string) *exec.Cmd {
|
||||
modVendor := exec.Command("go", "mod", "vendor")
|
||||
modVendor.Dir = path
|
||||
return modVendor
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user