From 0265573bc6817d30de1eac032bf87c0fe30ca0c7 Mon Sep 17 00:00:00 2001 From: rahulroy9202 Date: Tue, 3 Mar 2015 19:22:07 +0530 Subject: [PATCH] now checks if input version is greater than latest --- src/nvm.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/nvm.go b/src/nvm.go index b888575..f16f2cd 100644 --- a/src/nvm.go +++ b/src/nvm.go @@ -119,6 +119,19 @@ func update() { // } } +fun checkVersionExceedsLatest(version) 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 available.") + return + } + if cpuarch == "64" && !web.IsNode64bitAvailable(version) { fmt.Println("Node.js v"+version+" is only available in 32-bit.") return