Browse Source

Removed dep of target for install

pull/103/head
Unknown 11 years ago
parent
commit
e86bb84e83
  1. 21
      cmd/bin.go
  2. 4
      cmd/get.go
  3. 7
      cmd/gopath.go
  4. 9
      cmd/install.go
  5. 3
      doc/conf.go

21
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")

4
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] {

7
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) {

9
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"}

3
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())

Loading…
Cancel
Save