提交 7c456000 编写于 作者: K Kyle Wuolle

wildcard major version to latest X.y..z

added check in install function so that if only the major version number is specified, the latest version of that will be installed

fixes 214
上级 51d8e7e8
......@@ -168,7 +168,13 @@ func install(version string, cpuarch string) {
version = reg.ReplaceAllString(re.FindString(content),"")
}
version = cleanVersion(version)
// if the user specifies only the major version number then install the latest
// version of the major version number
if len(version) == 1 {
version = findLatestSubVersion(version)
} else {
version = cleanVersion(version)
}
if CheckVersionExceedsLatest(version) {
fmt.Println("Node.js v"+version+" is not yet released or available.")
......@@ -286,6 +292,15 @@ func uninstall(version string) {
return
}
func findLatestSubVersion(version string) string {
url := web.GetFullNodeUrl("latest-v" + version + ".x" + "/SHASUMS256.txt")
content := web.GetRemoteTextFile(url)
re := regexp.MustCompile("node-v(.+)+msi")
reg := regexp.MustCompile("node-v|-x.+")
latest := reg.ReplaceAllString(re.FindString(content), "")
return latest
}
func cleanVersion(version string) string {
re := regexp.MustCompile("\\d+.\\d+.\\d+")
matched := re.FindString(version)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册