Merge pull request #512 from EEJesse/add-support-for-use-latest

add support for "use latest"
This commit is contained in:
Corey Butler
2021-09-10 23:59:04 -05:00
committed by GitHub

View File

@@ -384,7 +384,15 @@ func findLatestSubVersion(version string) string {
}
func use(version string, cpuarch string) {
if version == "32" || version == "64" {
if version == "latest" {
installed := node.GetInstalled(env.root)
if len(installed) == 0 {
fmt.Println("No versions of node.js found. Try installing the latest by typing nvm install latest")
return
}
version = installed[0]
} else if version == "32" || version == "64" {
cpuarch = version
v, _ := node.GetCurrentVersion()
version = v
@@ -603,7 +611,7 @@ func help() {
fmt.Println(" nvm npm_mirror [url] : Set the npm mirror. Defaults to https://github.com/npm/cli/archive/. Leave [url] blank to default url.")
fmt.Println(" nvm uninstall <version> : The version must be a specific version.")
// fmt.Println(" nvm update : Automatically update nvm to the latest version.")
fmt.Println(" nvm use [version] [arch] : Switch to use the specified version. Optionally specify 32/64bit architecture.")
fmt.Println(" nvm use [version] [arch] : Switch to use the specified version or use \"latest\" to switch to the latest installed version. Optionally specify 32/64bit architecture.")
fmt.Println(" nvm use <arch> will continue using the selected version, but switch to 32/64 bit mode.")
fmt.Println(" nvm root [path] : Set the directory where nvm should store different versions of node.js.")
fmt.Println(" If <path> is not set, the current root will be displayed.")