generate: Set correct working directory for go mod download
This commit is contained in:
parent
631293329e
commit
ecb0d11088
2 changed files with 8 additions and 6 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"io"
|
||||
"io/ioutil"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
|
@ -29,7 +30,8 @@ type goModDownload struct {
|
|||
GoModSum string
|
||||
}
|
||||
|
||||
func GeneratePkgs(goModPath string, goMod2NixPath string) ([]*schema.Package, error) {
|
||||
func GeneratePkgs(directory string, goMod2NixPath string) ([]*schema.Package, error) {
|
||||
goModPath := filepath.Join(directory, "go.mod")
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"modPath": goModPath,
|
||||
|
@ -57,9 +59,11 @@ func GeneratePkgs(goModPath string, goMod2NixPath string) ([]*schema.Package, er
|
|||
{
|
||||
log.Info("Downloading dependencies")
|
||||
|
||||
stdout, err := exec.Command(
|
||||
cmd := exec.Command(
|
||||
"go", "mod", "download", "--json",
|
||||
).Output()
|
||||
)
|
||||
cmd.Dir = directory
|
||||
stdout, err := cmd.Output()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
4
main.go
4
main.go
|
@ -21,11 +21,9 @@ func main() {
|
|||
outDir = *directory
|
||||
}
|
||||
|
||||
goModPath := filepath.Join(*directory, "go.mod")
|
||||
|
||||
goMod2NixPath := filepath.Join(outDir, "gomod2nix.toml")
|
||||
outFile := goMod2NixPath
|
||||
pkgs, err := generate.GeneratePkgs(goModPath, goMod2NixPath)
|
||||
pkgs, err := generate.GeneratePkgs(*directory, goMod2NixPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue