coreybutler / nvm-windows

A node.js version management utility for Windows. Ironically written in Go.
MIT License
37.84k stars 3.35k forks source link

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

Open coreybutler opened 1 year ago

coreybutler commented 1 year ago

Discussed in https://github.com/coreybutler/nvm-windows/discussions/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](https://github.com/coreybutler/nvm-windows/assets/7733197/e9af82b1-17bd-4ccd-ab80-4e455cdf9be3) 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](https://github.com/coreybutler/nvm-windows/assets/7733197/c6b92911-ccd3-4baa-9c9c-3c92779762f5) 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](https://github.com/coreybutler/nvm-windows/assets/7733197/f6584776-61e3-41d0-bf41-feeb54fd985e)
github-actions[bot] commented 1 year ago

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[bot] commented 1 year ago

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