File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
12
12
"./nvm/arch"
13
13
"./nvm/file"
14
14
"./nvm/node"
15
+ "strconv"
15
16
"github.com/olekukonko/tablewriter"
16
17
)
17
18
@@ -144,12 +145,19 @@ func CheckVersionExceedsLatest(version string) bool{
144
145
re := regexp .MustCompile ("node-v(.+)+msi" )
145
146
reg := regexp .MustCompile ("node-v|-x.+" )
146
147
latest := reg .ReplaceAllString (re .FindString (content ),"" )
147
-
148
- if version <= latest {
149
- return false
150
- } else {
151
- return true
148
+ var vArr = strings .Split (version ,"." )
149
+ var lArr = strings .Split (latest , "." )
150
+ for index := range lArr {
151
+ lat ,_ := strconv .Atoi (lArr [index ])
152
+ ver ,_ := strconv .Atoi (vArr [index ])
153
+ //Should check for valid input (checking for conversion errors) but this tool is made to trust the user
154
+ if ver < lat {
155
+ return false
156
+ } else if ver > lat {
157
+ return true
158
+ }
152
159
}
160
+ return false
153
161
}
154
162
155
163
func install (version string , cpuarch string ) {
@@ -197,7 +205,6 @@ func install(version string, cpuarch string) {
197
205
fmt .Println ("Node.js v" + version + " is not yet released or available." )
198
206
return
199
207
}
200
-
201
208
if cpuarch == "64" && ! web .IsNode64bitAvailable (version ) {
202
209
fmt .Println ("Node.js v" + version + " is only available in 32-bit." )
203
210
return
You can’t perform that action at this time.
0 commit comments