Browse Source

Removed dep of target for install

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

8
.gopmfile

@ -2,8 +2,8 @@
path=github.com/gpmgo/gopm path=github.com/gpmgo/gopm
[deps] [deps]
github.com/codegangsta/cli= github.com/codegangsta/cli=
github.com/Unknwon/com= github.com/Unknwon/com=
github.com/Unknwon/goconfig= github.com/Unknwon/goconfig=
github.com/aybabtme/color= github.com/aybabtme/color=

21
cmd/bin.go

@ -18,6 +18,7 @@ import (
"fmt" "fmt"
"os" "os"
"path" "path"
"path/filepath"
"runtime" "runtime"
"strings" "strings"
@ -136,12 +137,26 @@ func runBin(ctx *cli.Context) {
}() }()
// Check if previous steps were successful. // Check if previous steps were successful.
binName := path.Base(pkgPath) if com.IsFile(doc.GopmFileName) {
binPath := path.Join(VENDOR, "src", binName) 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" { if runtime.GOOS == "windows" {
binName += ".exe" binName += ".exe"
} }
binPath = path.Join(binPath, binName) binPath := path.Join(VENDOR, "src", pkgPath, binName)
if !com.IsFile(binPath) { if !com.IsFile(binPath) {
log.Error("Bin", "Fail to continue command") log.Error("Bin", "Fail to continue command")
log.Fatal("", "Previous steps weren't successful or the project does not contain main package") 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) copyToGopath(installPath, gopathDir)
} }
continue 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] { if !downloadCache[n.ImportPath] {

7
cmd/gopath.go

@ -190,13 +190,6 @@ func genNewGoPath(ctx *cli.Context, isTest bool) {
log.Fatal("", err.Error()) 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" installRepoPath = doc.HomeDir + "/repos"
if com.IsFile(curPath + "/" + doc.GopmFileName) { if com.IsFile(curPath + "/" + doc.GopmFileName) {

9
cmd/install.go

@ -44,14 +44,11 @@ func runInstall(ctx *cli.Context) {
switch len(ctx.Args()) { switch len(ctx.Args()) {
case 0: case 0:
if !com.IsFile(".gopmfile") { if !com.IsFile(".gopmfile") {
log.Fatal("Install", "No gopmfile exist in work directory") break
} }
gf := doc.NewGopmfile(".") gf := doc.NewGopmfile(".")
target = gf.MustValue("target", "path") target = gf.MustValue("target", "path")
if len(target) == 0 {
log.Fatal("Install", "Cannot find target in gopmfile")
}
case 1: case 1:
target = ctx.Args()[0] target = ctx.Args()[0]
default: default:
@ -60,6 +57,10 @@ func runInstall(ctx *cli.Context) {
genNewGoPath(ctx, false) genNewGoPath(ctx, false)
if len(target) == 0 {
target = pkgName
}
log.Trace("Installing...") log.Trace("Installing...")
cmdArgs := []string{"go", "install"} cmdArgs := []string{"go", "install"}

3
doc/conf.go

@ -16,6 +16,7 @@ package doc
import ( import (
"os" "os"
"path"
"strings" "strings"
"github.com/Unknwon/com" "github.com/Unknwon/com"
@ -48,7 +49,7 @@ func init() {
} }
func NewGopmfile(dirPath string) *goconfig.ConfigFile { func NewGopmfile(dirPath string) *goconfig.ConfigFile {
gf, err := goconfig.LoadConfigFile(dirPath + "/" + GopmFileName) gf, err := goconfig.LoadConfigFile(path.Join(dirPath, GopmFileName))
if err != nil { if err != nil {
log.Error("", "Fail to load gopmfile") log.Error("", "Fail to load gopmfile")
log.Fatal("", err.Error()) log.Fatal("", err.Error())

Loading…
Cancel
Save