Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nvm use to be called with the part of the semver #709

Merged
merged 1 commit into from
May 12, 2022

Conversation

vladonemo
Copy link
Contributor

For instance, the nvm use 12 will switch to the latest installed version of 12.. Similarly, nvm use 12.22 will switch to the latest installed version of 12.22.

Fixes #708

@vladonemo
Copy link
Contributor Author

@coreybutler any chance of reviewing this one? Thanks

@coreybutler
Copy link
Owner

Not during the holiday break.

src/nvm.go Show resolved Hide resolved
@vladonemo
Copy link
Contributor Author

@coreybutler any chance you get around to it? This utility is great, would be awesome to improve the usability here

@github-actions
Copy link

github-actions bot commented Mar 6, 2022

This PR is stale because it has been open 45 days with no activity.

@github-actions github-actions bot added the Stale Stale label Mar 6, 2022
@coreybutler coreybutler removed the Stale Stale label Mar 8, 2022
Copy link
Owner

@coreybutler coreybutler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, except for the removed error handling. See comments for details.

src/nvm.go Show resolved Hide resolved
@ajmeese7
Copy link

@vladonemo have you had a chance to check out the comments above? I would love to see it merged!

@vladonemo vladonemo force-pushed the use_command_enhacement branch from 55850f2 to d55a320 Compare March 14, 2022 07:36
@github-actions
Copy link

This PR is stale because it has been open 45 days with no activity.

@github-actions github-actions bot added the Stale Stale label Apr 14, 2022
@coreybutler coreybutler removed the Stale Stale label Apr 14, 2022
@vladonemo
Copy link
Contributor Author

@coreybutler I have reverted the error handling changes long time back. Any chance merging this one?

src/nvm.go Outdated
func findLatestSubVersion(version string, localOnly ...bool) string {
if len(localOnly) > 0 && localOnly[0] {
installed := node.GetInstalled(env.root)
result := ""
for _, v := range installed {
if strings.HasPrefix(v, "v"+version) {
if result != "" {
current, _ := semver.New(strings.Replace(result, "v", "", 1))
next, _ := semver.New(strings.Replace(v, "v", "", 1))
current, _ := semver.New(versionNumberFrom(v))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be referring to the 'result' variable, instead of v like the result variable above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, thanks a lot. Yep, right. Though it doesn't really matter in the context this piece of code is called - the list of versions is sorted descending, hence the first version in the list is always the latest one.

For instance, the `nvm use 12` will switch to the latest installed version of 12.*. Similarly, `nvm use 12.22` will switch to the latest installed version of 12.22.*

Fixes coreybutler#708
@vladonemo vladonemo force-pushed the use_command_enhacement branch from d55a320 to 9f3af8a Compare April 21, 2022 19:31
@vladonemo
Copy link
Contributor Author

@coreybutler I had to change the error handling mentioned above once more. After I added it back (on your request), the most important use cases of this feature PR stopped working (e.g. nvm use 16 reported node v16.14.2 (64-bit) is not installed or cannot be found. even though it was installed)

@r3faat1
Copy link

r3faat1 commented Apr 25, 2022

Can we get this or similar implemented soon? The command nvm use 16 is throwing error: node vv16.14.0 (64-bit) is not installed or cannot be found.

src/nvm.go Show resolved Hide resolved
@vladonemo
Copy link
Contributor Author

@coreybutler this PR has been open since half a year now. Is there any chance that it gets closed? I'd like to avoid distributing a patched version to our teams and use the official release instead.

@coreybutler coreybutler merged commit e75c744 into coreybutler:master May 12, 2022
@coreybutler
Copy link
Owner

Merged. This will be in the next release, but there are several other PRs to review before I can cut a new release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nvm use reports that the version was not installed or could not be found
6 participants