Open
Description
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".
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.
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
}