mirror of
https://github.com/coreybutler/nvm-windows.git
synced 2026-01-15 07:04:31 +08:00
fix: node v4 support works
fix: 'install latest' works fix: current version arch works
This commit is contained in:
20
src/nvm.go
20
src/nvm.go
@@ -120,11 +120,11 @@ func update() {
|
||||
}
|
||||
|
||||
func CheckVersionExceedsLatest(version string) bool{
|
||||
content := web.GetRemoteTextFile("http://nodejs.org/dist/latest/SHASUMS.txt")
|
||||
content := web.GetRemoteTextFile("http://nodejs.org/dist/latest/SHASUMS256.txt")
|
||||
re := regexp.MustCompile("node-v(.+)+msi")
|
||||
reg := regexp.MustCompile("node-v|-x.+")
|
||||
latest := reg.ReplaceAllString(re.FindString(content),"")
|
||||
|
||||
|
||||
if version <= latest {
|
||||
return false
|
||||
} else {
|
||||
@@ -155,6 +155,14 @@ func install(version string, cpuarch string) {
|
||||
cpuarch = arch.Validate(cpuarch)
|
||||
}
|
||||
|
||||
// If user specifies "latest" version, find out what version is
|
||||
if version == "latest" {
|
||||
content := web.GetRemoteTextFile("http://nodejs.org/dist/latest/SHASUMS256.txt")
|
||||
re := regexp.MustCompile("node-v(.+)+msi")
|
||||
reg := regexp.MustCompile("node-v|-x.+")
|
||||
version = reg.ReplaceAllString(re.FindString(content),"")
|
||||
}
|
||||
|
||||
if CheckVersionExceedsLatest(version) {
|
||||
fmt.Println("Node.js v"+version+" is not yet released or available.")
|
||||
return
|
||||
@@ -165,14 +173,6 @@ func install(version string, cpuarch string) {
|
||||
return
|
||||
}
|
||||
|
||||
// If user specifies "latest" version, find out what version is
|
||||
if version == "latest" {
|
||||
content := web.GetRemoteTextFile("http://nodejs.org/dist/latest/SHASUMS.txt")
|
||||
re := regexp.MustCompile("node-v(.+)+msi")
|
||||
reg := regexp.MustCompile("node-v|-x.+")
|
||||
version = reg.ReplaceAllString(re.FindString(content),"")
|
||||
}
|
||||
|
||||
// Check to see if the version is already installed
|
||||
if !node.IsVersionInstalled(env.root,version,cpuarch) {
|
||||
|
||||
|
||||
@@ -25,17 +25,21 @@ func GetCurrentVersion() (string, string) {
|
||||
cmd := exec.Command("node","-p","console.log(process.execPath)")
|
||||
str, _ := cmd.Output()
|
||||
file := strings.Trim(regexp.MustCompile("undefined").ReplaceAllString(string(str),"")," \n\r")
|
||||
bit := arch.Bit(file)
|
||||
if (bit == "?"){
|
||||
cmd := exec.Command("node", "-e", "console.log(process.arch)" )
|
||||
str, err := cmd.Output()
|
||||
if (string(str) == "x64") {
|
||||
bit := "64"
|
||||
} else {
|
||||
bit := "32"
|
||||
}
|
||||
}
|
||||
return v, bit
|
||||
bit := arch.Bit(file)
|
||||
if (bit == "?"){
|
||||
cmd := exec.Command("node", "-e", "console.log(process.arch)" )
|
||||
str, err := cmd.Output()
|
||||
if (err == nil) {
|
||||
if (string(str) == "x64") {
|
||||
bit = "64"
|
||||
} else {
|
||||
bit = "32"
|
||||
}
|
||||
} else {
|
||||
return v, "Unknown"
|
||||
}
|
||||
}
|
||||
return v, bit
|
||||
}
|
||||
return "Unknown",""
|
||||
}
|
||||
|
||||
@@ -142,6 +142,23 @@ func GetRemoteTextFile(url string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func IsNode64bitAvailable(v string) bool {
|
||||
if v == "latest" {
|
||||
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
|
||||
}
|
||||
|
||||
// TODO: fixme. Assume a 64 bit version exists
|
||||
return true
|
||||
}
|
||||
|
||||
func getNodeUrl (v string, vpre string) string {
|
||||
url := "http://nodejs.org/dist/v"+v+"/" + vpre + "/node.exe"
|
||||
// Check online to see if a 64 bit version exists
|
||||
|
||||
Reference in New Issue
Block a user