Skip to content

Commit

Permalink
Suppot space in path.
Browse files Browse the repository at this point in the history
  • Loading branch information
wsobolewski committed Feb 25, 2024
1 parent 6003488 commit 03f418c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/nvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ type Environment struct {

var home = filepath.Clean(os.Getenv("NVM_HOME") + "\\settings.txt")
var symlink = filepath.Clean(os.Getenv("NVM_SYMLINK"))
var root = filepath.Clean(os.Getenv("NVM_HOME"))

var env = &Environment{
settings: home,
root: "",
root: root,
symlink: symlink,
arch: strings.ToLower(os.Getenv("PROCESSOR_ARCHITECTURE")),
node_mirror: "",
Expand Down Expand Up @@ -1467,6 +1468,7 @@ func saveSettings() {
content := "root: " + strings.Trim(encode(env.root), " \n\r") + "\r\narch: " + strings.Trim(encode(env.arch), " \n\r") + "\r\nproxy: " + strings.Trim(encode(env.proxy), " \n\r") + "\r\noriginalpath: " + strings.Trim(encode(env.originalpath), " \n\r") + "\r\noriginalversion: " + strings.Trim(encode(env.originalversion), " \n\r")
content = content + "\r\nnode_mirror: " + strings.Trim(encode(env.node_mirror), " \n\r") + "\r\nnpm_mirror: " + strings.Trim(encode(env.npm_mirror), " \n\r")
ioutil.WriteFile(env.settings, []byte(content), 0644)
os.Setenv("NVM_HOME", strings.Trim(encode(env.root), " \n\r"))
}

func getProcessPermissions() (admin bool, elevated bool, err error) {
Expand Down Expand Up @@ -1525,8 +1527,8 @@ func setup() {
m[res[0]] = strings.TrimSpace(strings.Join(res[1:], ":"))
}

if val, ok := m["root"]; ok {
env.root = filepath.Clean(val)
if _, ok := m["root"]; ok {
env.root = filepath.Clean(os.Getenv("NVM_HOME"))
}
if val, ok := m["originalpath"]; ok {
env.originalpath = filepath.Clean(val)
Expand Down

1 comment on commit 03f418c

@wsobolewski
Copy link
Owner Author

Choose a reason for hiding this comment

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

Support utf-8 characters in path.

Please sign in to comment.