From e86bb84e83f79109b61cc50a844c722321bd5b1a Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 3 Dec 2013 04:01:45 -0500 Subject: [PATCH] Removed dep of target for install --- .gopmfile | 8 ++++---- cmd/bin.go | 21 ++++++++++++++++++--- cmd/get.go | 4 ++-- cmd/gopath.go | 7 ------- cmd/install.go | 9 +++++---- doc/conf.go | 3 ++- 6 files changed, 31 insertions(+), 21 deletions(-) diff --git a/.gopmfile b/.gopmfile index 086c3463a..103a06e97 100644 --- a/.gopmfile +++ b/.gopmfile @@ -2,8 +2,8 @@ path=github.com/gpmgo/gopm [deps] -github.com/codegangsta/cli= -github.com/Unknwon/com= -github.com/Unknwon/goconfig= -github.com/aybabtme/color= +github.com/codegangsta/cli= +github.com/Unknwon/com= +github.com/Unknwon/goconfig= +github.com/aybabtme/color= diff --git a/cmd/bin.go b/cmd/bin.go index 9396bdcb8..9daddf3b6 100644 --- a/cmd/bin.go +++ b/cmd/bin.go @@ -18,6 +18,7 @@ import ( "fmt" "os" "path" + "path/filepath" "runtime" "strings" @@ -136,12 +137,26 @@ func runBin(ctx *cli.Context) { }() // Check if previous steps were successful. - binName := path.Base(pkgPath) - binPath := path.Join(VENDOR, "src", binName) + if com.IsFile(doc.GopmFileName) { + log.Trace("Loading gopmfile...") + gf := doc.NewGopmfile(".") + + var err error + pkgName, err = gf.GetValue("target", "path") + if err == nil { + log.Log("Target name: %s", pkgName) + } + } + + if len(pkgName) == 0 { + _, pkgName = filepath.Split(pkgPath) + } + + binName := path.Base(pkgName) if runtime.GOOS == "windows" { binName += ".exe" } - binPath = path.Join(binPath, binName) + binPath := path.Join(VENDOR, "src", pkgPath, binName) if !com.IsFile(binPath) { log.Error("Bin", "Fail to continue command") log.Fatal("", "Previous steps weren't successful or the project does not contain main package") diff --git a/cmd/get.go b/cmd/get.go index 9ec1e78e6..455eed0d0 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -215,9 +215,9 @@ func downloadPackages(ctx *cli.Context, nodes []*doc.Node) { copyToGopath(installPath, gopathDir) } continue + } else { + doc.LocalNodes.SetValue(doc.GetProjectPath(n.ImportPath), "value", "") } - } else if !com.IsExist(installPath) { - doc.LocalNodes.SetValue(doc.GetProjectPath(n.ImportPath), "value", "") } if !downloadCache[n.ImportPath] { diff --git a/cmd/gopath.go b/cmd/gopath.go index 7d2159b4c..4fadd9020 100644 --- a/cmd/gopath.go +++ b/cmd/gopath.go @@ -190,13 +190,6 @@ func genNewGoPath(ctx *cli.Context, isTest bool) { log.Fatal("", err.Error()) } - hd, err := com.HomeDir() - if err != nil { - log.Error("", "Fail to get current user") - log.Fatal("", err.Error()) - } - - doc.HomeDir = strings.Replace(doc.RawHomeDir, "~", hd, -1) installRepoPath = doc.HomeDir + "/repos" if com.IsFile(curPath + "/" + doc.GopmFileName) { diff --git a/cmd/install.go b/cmd/install.go index 0d25f4fc5..5973ba60f 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -44,14 +44,11 @@ func runInstall(ctx *cli.Context) { switch len(ctx.Args()) { case 0: if !com.IsFile(".gopmfile") { - log.Fatal("Install", "No gopmfile exist in work directory") + break } gf := doc.NewGopmfile(".") target = gf.MustValue("target", "path") - if len(target) == 0 { - log.Fatal("Install", "Cannot find target in gopmfile") - } case 1: target = ctx.Args()[0] default: @@ -60,6 +57,10 @@ func runInstall(ctx *cli.Context) { genNewGoPath(ctx, false) + if len(target) == 0 { + target = pkgName + } + log.Trace("Installing...") cmdArgs := []string{"go", "install"} diff --git a/doc/conf.go b/doc/conf.go index 584d5fc2b..82f8374e8 100644 --- a/doc/conf.go +++ b/doc/conf.go @@ -16,6 +16,7 @@ package doc import ( "os" + "path" "strings" "github.com/Unknwon/com" @@ -48,7 +49,7 @@ func init() { } func NewGopmfile(dirPath string) *goconfig.ConfigFile { - gf, err := goconfig.LoadConfigFile(dirPath + "/" + GopmFileName) + gf, err := goconfig.LoadConfigFile(path.Join(dirPath, GopmFileName)) if err != nil { log.Error("", "Fail to load gopmfile") log.Fatal("", err.Error())