mirror of
https://github.com/coreybutler/nvm-windows.git
synced 2026-01-14 07:03:17 +08:00
Merge pull request #45 from rahulroy9202/master
Now checks if input version is greater than latest and alerts user accordingly. Closes #44
This commit is contained in:
20
src/nvm.go
20
src/nvm.go
@@ -119,6 +119,19 @@ func update() {
|
||||
// }
|
||||
}
|
||||
|
||||
func CheckVersionExceedsLatest(version string) bool{
|
||||
content := web.GetRemoteTextFile("http://nodejs.org/dist/latest/SHASUMS.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 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func install(version string, cpuarch string) {
|
||||
if version == "" {
|
||||
fmt.Println("\nInvalid version.")
|
||||
@@ -141,7 +154,12 @@ func install(version string, cpuarch string) {
|
||||
if cpuarch != "all" {
|
||||
cpuarch = arch.Validate(cpuarch)
|
||||
}
|
||||
|
||||
|
||||
if CheckVersionExceedsLatest(version) {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user