Skip to content

Commit

Permalink
Merge pull request #269 from Graren/master
Browse files Browse the repository at this point in the history
#268 Fixed comparison in exceeds latest
  • Loading branch information
coreybutler committed May 10, 2017
2 parents 496971a + e0fe490 commit 5b70c75
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/nvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"./nvm/arch"
"./nvm/file"
"./nvm/node"
"strconv"
"github.com/olekukonko/tablewriter"
)

Expand Down Expand Up @@ -144,12 +145,19 @@ func CheckVersionExceedsLatest(version string) bool{
re := regexp.MustCompile("node-v(.+)+msi")
reg := regexp.MustCompile("node-v|-x.+")
latest := reg.ReplaceAllString(re.FindString(content),"")

if version <= latest {
return false
} else {
return true
var vArr = strings.Split(version,".")
var lArr = strings.Split(latest, ".")
for index := range lArr {
lat,_ := strconv.Atoi(lArr[index])
ver,_ := strconv.Atoi(vArr[index])
//Should check for valid input (checking for conversion errors) but this tool is made to trust the user
if ver < lat {
return false
} else if ver > lat {
return true
}
}
return false
}

func install(version string, cpuarch string) {
Expand Down Expand Up @@ -197,7 +205,6 @@ func install(version string, cpuarch string) {
fmt.Println("Node.js v"+version+" is not yet released or available.")
return
}

if cpuarch == "64" && !web.IsNode64bitAvailable(version) {
fmt.Println("Node.js v"+version+" is only available in 32-bit.")
return
Expand Down

0 comments on commit 5b70c75

Please sign in to comment.