Skip to content

Commit

Permalink
coreybutler#79 use junctions when mklink, avoid elevated permission
Browse files Browse the repository at this point in the history
  • Loading branch information
h404bi committed Jul 9, 2017
1 parent 78f143d commit 89b8e2b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 37 deletions.
5 changes: 0 additions & 5 deletions bin/elevate.cmd

This file was deleted.

13 changes: 0 additions & 13 deletions bin/elevate.vbs

This file was deleted.

15 changes: 0 additions & 15 deletions bin/install.cmd

This file was deleted.

8 changes: 4 additions & 4 deletions src/nvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func uninstall(version string) {
fmt.Printf("Uninstalling node v" + version + "...")
v, _ := node.GetCurrentVersion()
if v == version {
cmd := exec.Command(filepath.Join(env.root, "elevate.cmd"), "cmd", "/C", "rmdir", env.symlink)
cmd := exec.Command("cmd", "/C", "rmdir", env.symlink)
cmd.Run()
}
e := os.RemoveAll(filepath.Join(env.root, "v"+version))
Expand Down Expand Up @@ -387,7 +387,7 @@ func use(version string, cpuarch string) {
// Create or update the symlink
sym, _ := os.Stat(env.symlink)
if sym != nil {
cmd := exec.Command(filepath.Join(env.root, "elevate.cmd"), "cmd", "/C", "rmdir", env.symlink)
cmd := exec.Command("cmd", "/C", "rmdir", env.symlink)
var output bytes.Buffer
var _stderr bytes.Buffer
cmd.Stdout = &output
Expand All @@ -399,7 +399,7 @@ func use(version string, cpuarch string) {
}
}

c := exec.Command(filepath.Join(env.root, "elevate.cmd"), "cmd", "/C", "mklink", "/D", env.symlink, filepath.Join(env.root, "v"+version))
c := exec.Command("cmd", "/C", "mklink", "/J", env.symlink, filepath.Join(env.root, "v"+version))
var out bytes.Buffer
var stderr bytes.Buffer
c.Stdout = &out
Expand Down Expand Up @@ -558,7 +558,7 @@ func enable() {
}

func disable() {
cmd := exec.Command(filepath.Join(env.root, "elevate.cmd"), "cmd", "/C", "rmdir", env.symlink)
cmd := exec.Command("cmd", "/C", "rmdir", env.symlink)
cmd.Run()
fmt.Println("nvm disabled")
}
Expand Down

0 comments on commit 89b8e2b

Please sign in to comment.