提交 44719321 编写于 作者: M Michael-Rainabba Richardson

Finish newx64FolderNameSupport

#define MyAppName "NVM for Windows" #define MyAppName "NVM for Windows"
#define MyAppShortName "nvm" #define MyAppShortName "nvm"
#define MyAppLCShortName "nvm" #define MyAppLCShortName "nvm"
#define MyAppVersion "1.0.6" #define MyAppVersion "1.1.0"
#define MyAppPublisher "Ecor Ventures, LLC" #define MyAppPublisher "Ecor Ventures, LLC"
#define MyAppURL "http://github.com/coreybutler/nvm" #define MyAppURL "http://github.com/coreybutler/nvm"
#define MyAppExeName "nvm.exe" #define MyAppExeName "nvm.exe"
......
...@@ -18,7 +18,7 @@ import ( ...@@ -18,7 +18,7 @@ import (
) )
const ( const (
NvmVersion = "1.0.6" NvmVersion = "1.1.0"
) )
type Environment struct { type Environment struct {
......
...@@ -59,26 +59,42 @@ func GetNodeJS(root string, v string, a string) bool { ...@@ -59,26 +59,42 @@ func GetNodeJS(root string, v string, a string) bool {
a = arch.Validate(a) a = arch.Validate(a)
url := "" vpre := ""
vers := strings.Fields(strings.Replace(v,"."," ",-1))
main, _ := strconv.ParseInt(vers[0],0,0)
if a == "32" { if a == "32" {
url = "http://nodejs.org/dist/v"+v+"/node.exe" if main > 0 {
} else { vpre = "win-x86/"
if !IsNode64bitAvailable(v) { } else {
fmt.Println("Node.js v"+v+" is only available in 32-bit.") vpre = ""
return false }
} else if a == "64" {
if main > 0 {
vpre = "win-x64/"
} else {
vpre = "x64/"
} }
url = "http://nodejs.org/dist/v"+v+"/x64/node.exe"
} }
fileName := root+"\\v"+v+"\\node"+a+".exe"
url := getNodeUrl ( v, vpre );
fmt.Printf("Downloading node.js version "+v+" ("+a+"-bit)... ")
if Download(url,fileName) { if url == "" {
fmt.Printf("Complete\n") //No url should mean this version/arch isn't available
return true fmt.Println("Node.js v"+v+" " + a + "bit isn't available right now.")
} else { } else {
return false fileName := root+"\\v"+v+"\\node"+a+".exe"
fmt.Printf("Downloading node.js version "+v+" ("+a+"-bit)... ")
if Download(url,fileName) {
fmt.Printf("Complete\n")
return true
} else {
return false
}
} }
return false
} }
...@@ -126,23 +142,16 @@ func GetRemoteTextFile(url string) string { ...@@ -126,23 +142,16 @@ func GetRemoteTextFile(url string) string {
return "" return ""
} }
func IsNode64bitAvailable(v string) bool { func getNodeUrl (v string, vpre string) string {
if v == "latest" { url := "http://nodejs.org/dist/v"+v+"/" + vpre + "/node.exe"
return true
}
// Anything below version 8 doesn't have a 64 bit version
vers := strings.Fields(strings.Replace(v,"."," ",-1))
main, _ := strconv.ParseInt(vers[0],0,0)
minor, _ := strconv.ParseInt(vers[1],0,0)
if main == 0 && minor < 8 {
return false
}
// Check online to see if a 64 bit version exists // Check online to see if a 64 bit version exists
res, err := client.Head("http://nodejs.org/dist/v"+v+"/x64/node.exe") res, err := client.Head( url )
if err != nil { if err != nil {
return false return ""
}
if res.StatusCode == 200 {
return url
} else {
return ""
} }
return res.StatusCode == 200
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册