Browse Source

auto-detect package path of gpm, so binary can be put in any path that is in /c/Users/Unknown/bin:.:/usr/local/bin:/mingw/bin:/bin:/c/Program Files/Common Files/Microsoft Shared/Windows Live:/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/c/Program Files (x86)/Windows Live/Shared:/c/Program Files/Intel/WiFi/bin/:/c/Program Files/Common Files/Intel/WirelessCommon/:/c/Program Files/Microsoft/Web Platform Installer/:/c/Program Files (x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0/:/c/Program Files (x86)/Windows Kits/8.0/Windows Performance Toolkit/:/c/Program Files/Microsoft SQL Server/110/Tools/Binn/:/d/TortoiseHg/:/d/Qt/Qt5.0.1/5.0.1/msvc2010/bin:/d/Java/jdk1.7.0_17/bin:/d/Java/jdk1.7.0_17/jre/bin:/d/MinGW64/bin:/d/MinGW/bin:/c/Program Files/MySQL/MySQL Server 5.1/bin:/d/go/bin:/cmd:/bin:/e/Go/Development/src/github.com/GPMGo/gpm

pull/103/head
Unknown 12 years ago
parent
commit
77162ada68
  1. 2
      README.md
  2. 2
      conf/gpm.toml
  3. 13
      gpm.go

2
README.md

@ -35,8 +35,6 @@ This application still in experiment, any change could happen, but it doesn't af
### v0.2.*
- Add feature auto-catch if run under GOPATH/bin.
### Future
- Command `check` add feature to update or generate gopack.json.

2
conf/gpm.toml

@ -1,7 +1,7 @@
# This is a configuration file for gpm with toml format.
title = "gpm(Go Package Manager)"
version = "v0.2.0 Build 0524"
version = "v0.2.1 Build 0524"
user_language = "en-US"
#user_language = "zh-CN"
auto_backup = true

13
gpm.go

@ -114,16 +114,25 @@ func getAppPath() bool {
// Look up executable in PATH variable.
appPath, _ = exec.LookPath(path.Base(os.Args[0]))
// Check if run under $GOPATH/bin
if !utils.IsExist(appPath + "conf/") {
paths := utils.GetGOPATH()
for _, p := range paths {
if utils.IsExist(p + "/src/github.com/GPMGo/gpm/") {
appPath = p + "/src/github.com/GPMGo/gpm/"
break
}
}
}
if len(appPath) == 0 {
fmt.Printf("ERROR: getAppPath -> Unable to indicate current execute path.\n")
return false
}
appPath += "/"
appPath = filepath.Dir(appPath) + "/"
if runtime.GOOS == "windows" {
// Replace all '\' to '/'.
appPath = strings.Replace(filepath.Dir(appPath), "\\", "/", -1)
appPath = strings.Replace(appPath, "\\", "/", -1)
}
doc.SetAppConfig(appPath, config.AutoBackup)

Loading…
Cancel
Save