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

Make the nvm list can detect the symlinks in the nvm-windows root directory #1031

Open
coreybutler opened this issue Sep 19, 2023 Discussed in #1030 · 2 comments
Open

Make the nvm list can detect the symlinks in the nvm-windows root directory #1031

coreybutler opened this issue Sep 19, 2023 Discussed in #1030 · 2 comments
Labels

Comments

@coreybutler
Copy link
Owner

Discussed in #1030

Originally posted by Humbunklung September 19, 2023
The nodejs installed by Visual Studio work load, cannot be added to the nvm list, especially the one is not in the environment variable path. I can make symlinks in the root directory link the origin node path created by visual studio. For example, v16.14.0 links to "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VisualStudio\NodeJs".
image

However, the command "nvm list" can not list the node's symlinks added by me, because in the file node.go, files[i].IsDir() will return false, while files[i] is a symlink.
image
I modified the function GetInstalled like this:

func GetInstalled(root string) []string {
	list := make([]semver.Version, 0)
	files, _ := ioutil.ReadDir(root)

	for i := len(files) - 1; i >= 0; i-- {
		if files[i].IsDir() || (files[i].Mode()&os.ModeSymlink == os.ModeSymlink) {
			isnode, _ := regexp.MatchString("v", files[i].Name())

			if isnode {
				currentVersionString := strings.Replace(files[i].Name(), "v", "", 1)
				currentVersion, _ := semver.Make(currentVersionString)

				list = append(list, currentVersion)
			}
		}
	}

	semver.Sort(list)

	loggableList := make([]string, 0)

	for _, version := range list {
		loggableList = append(loggableList, "v"+version.String())
	}

	loggableList = reverseStringArray(loggableList)

	return loggableList
}

Then my problem solved, the symlinks are detected.
image

Humbunklung pushed a commit to Humbunklung/nvm-windows that referenced this issue Sep 20, 2023
coreybutler added a commit that referenced this issue Sep 20, 2023
Modified folder detection code against #1031
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale Stale label Oct 20, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2023
@coreybutler coreybutler added the consider for rt Pinned for use in the rt project label Oct 28, 2023
@coreybutler coreybutler reopened this Oct 28, 2023
@coreybutler coreybutler removed the Stale Stale label Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant