提交 fd7f7baf 编写于 作者: C Corey Butler 提交者: GitHub

Merge pull request #218 from bblanchon/fix-swap-32-64

Fix "nvm use" swapping node32 and node64 even when not need (issue #134)
...@@ -359,21 +359,23 @@ func use(version string, cpuarch string) { ...@@ -359,21 +359,23 @@ func use(version string, cpuarch string) {
// Use the assigned CPU architecture // Use the assigned CPU architecture
cpuarch = arch.Validate(cpuarch) cpuarch = arch.Validate(cpuarch)
e32 := file.Exists(env.root+"\\v"+version+"\\node32.exe") nodepath := env.root+"\\v"+version+"\\node.exe"
e64 := file.Exists(env.root+"\\v"+version+"\\node64.exe") node32path := env.root+"\\v"+version+"\\node32.exe"
used := file.Exists(env.root+"\\v"+version+"\\node.exe") node64path := env.root+"\\v"+version+"\\node64.exe"
if (e32 || e64) { node32exists := file.Exists(node32path)
if used { node64exists := file.Exists(node64path)
if e32 { nodeexists := file.Exists(nodepath)
os.Rename(env.root+"\\v"+version+"\\node.exe",env.root+"\\v"+version+"\\node64.exe") if node32exists && cpuarch == "32" { // user wants 32, but node.exe is 64
os.Rename(env.root+"\\v"+version+"\\node32.exe",env.root+"\\v"+version+"\\node.exe") if nodeexists {
} else { os.Rename(nodepath, node64path) // node.exe -> node64.exe
os.Rename(env.root+"\\v"+version+"\\node.exe",env.root+"\\v"+version+"\\node32.exe") }
os.Rename(env.root+"\\v"+version+"\\node64.exe",env.root+"\\v"+version+"\\node.exe") os.Rename(node32path, nodepath) // node32.exe -> node.exe
} }
} else if e32 || e64 { if node64exists && cpuarch == "64" { // user wants 64, but node.exe is 32
os.Rename(env.root+"\\v"+version+"\\node"+cpuarch+".exe",env.root+"\\v"+version+"\\node.exe") if nodeexists {
os.Rename(nodepath, node32path) // node.exe -> node32.exe
} }
os.Rename(node64path, nodepath) // node64.exe -> node.exe
} }
fmt.Println("Now using node v"+version+" ("+cpuarch+"-bit)") fmt.Println("Now using node v"+version+" ("+cpuarch+"-bit)")
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册