未验证 提交 476e11d1 编写于 作者: C Corey Butler 提交者: GitHub

Merge pull request #222 from kylewuolle/issue-214

wildcard major version to latest X.y..z
......@@ -204,7 +204,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.")
......@@ -350,6 +356,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.
先完成此消息的编辑!
想要评论请 注册