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:
Corey Butler
2015-03-03 09:17:43 -06:00

View File

@@ -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