@@ -711,10 +711,11 @@ func install(version string, cpuarch string) {
711
711
712
712
if file .Exists (filepath .Join (root , "v" + version , "node_modules" , "npm" )) {
713
713
utility .DebugLogf ("move %v to %v" , filepath .Join (root , "v" + version ), filepath .Join (env .root , "v" + version ))
714
- if rnerr := os .Rename (filepath .Join (root , "v" + version ), filepath .Join (env .root , "v" + version )); rnerr != nil {
714
+ if rnerr := utility .Rename (filepath .Join (root , "v" + version ), filepath .Join (env .root , "v" + version )); rnerr != nil {
715
715
status <- Status {Err : err }
716
716
}
717
717
utility .DebugFn (func () {
718
+ utility .DebugLogf ("env root: %v" , env .root )
718
719
cmd := exec .Command ("cmd" , "/C" , "dir" , filepath .Join (env .root , "v" + version ))
719
720
out , err := cmd .CombinedOutput ()
720
721
if err != nil {
@@ -768,13 +769,13 @@ func install(version string, cpuarch string) {
768
769
}
769
770
770
771
// Standard npm support
771
- os .Rename (filepath .Join (tempNpmBin , "npm" ), filepath .Join (root , "v" + version , "npm" ))
772
- os .Rename (filepath .Join (tempNpmBin , "npm.cmd" ), filepath .Join (root , "v" + version , "npm.cmd" ))
772
+ utility .Rename (filepath .Join (tempNpmBin , "npm" ), filepath .Join (root , "v" + version , "npm" ))
773
+ utility .Rename (filepath .Join (tempNpmBin , "npm.cmd" ), filepath .Join (root , "v" + version , "npm.cmd" ))
773
774
774
775
// npx support
775
776
if _ , err := os .Stat (filepath .Join (tempNpmBin , "npx" )); err == nil {
776
- os .Rename (filepath .Join (tempNpmBin , "npx" ), filepath .Join (root , "v" + version , "npx" ))
777
- os .Rename (filepath .Join (tempNpmBin , "npx.cmd" ), filepath .Join (root , "v" + version , "npx.cmd" ))
777
+ utility .Rename (filepath .Join (tempNpmBin , "npx" ), filepath .Join (root , "v" + version , "npx" ))
778
+ utility .Rename (filepath .Join (tempNpmBin , "npx.cmd" ), filepath .Join (root , "v" + version , "npx.cmd" ))
778
779
}
779
780
780
781
npmSourcePath := filepath .Join (tempDir , "nvm-npm" , "npm-" + npmv )
@@ -783,21 +784,20 @@ func install(version string, cpuarch string) {
783
784
npmSourcePath = filepath .Join (tempDir , "nvm-npm" , "cli-" + npmv )
784
785
}
785
786
786
- moveNpmErr := os .Rename (npmSourcePath , filepath .Join (root , "v" + version , "node_modules" , "npm" ))
787
+ moveNpmErr := utility .Rename (npmSourcePath , filepath .Join (root , "v" + version , "node_modules" , "npm" ))
787
788
if moveNpmErr != nil {
788
789
// sometimes Windows can take some time to enable access to large amounts of files after unzip, use exponential backoff to wait until it is ready
789
790
for _ , i := range [5 ]int {1 , 2 , 4 , 8 , 16 } {
790
791
time .Sleep (time .Duration (i ) * time .Second )
791
- moveNpmErr = os .Rename (npmSourcePath , filepath .Join (root , "v" + version , "node_modules" , "npm" ))
792
+ moveNpmErr = utility .Rename (npmSourcePath , filepath .Join (root , "v" + version , "node_modules" , "npm" ))
792
793
if moveNpmErr == nil {
793
794
break
794
795
}
795
796
}
796
-
797
797
}
798
798
799
799
if err == nil && moveNpmErr == nil {
800
- err = os .Rename (filepath .Join (root , "v" + version ), filepath .Join (env .root , "v" + version ))
800
+ err = utility .Rename (filepath .Join (root , "v" + version ), filepath .Join (env .root , "v" + version ))
801
801
if err != nil {
802
802
status <- Status {Err : err }
803
803
}
@@ -812,7 +812,7 @@ func install(version string, cpuarch string) {
812
812
status <- Status {Err : fmt .Errorf ("Failed to extract npm: %v" , err ), Done : true }
813
813
}
814
814
} else {
815
- err = os .Rename (filepath .Join (root , "v" + version ), filepath .Join (env .root , "v" + version ))
815
+ err = utility .Rename (filepath .Join (root , "v" + version ), filepath .Join (env .root , "v" + version ))
816
816
if err != nil {
817
817
status <- Status {Err : err }
818
818
}
@@ -1233,15 +1233,15 @@ func use(version string, cpuarch string, reload ...bool) {
1233
1233
nodeexists := file .Exists (nodepath )
1234
1234
if node32exists && cpuarch == "32" { // user wants 32, but node.exe is 64
1235
1235
if nodeexists {
1236
- os .Rename (nodepath , node64path ) // node.exe -> node64.exe
1236
+ utility .Rename (nodepath , node64path ) // node.exe -> node64.exe
1237
1237
}
1238
- os .Rename (node32path , nodepath ) // node32.exe -> node.exe
1238
+ utility .Rename (node32path , nodepath ) // node32.exe -> node.exe
1239
1239
}
1240
1240
if node64exists && cpuarch == "64" { // user wants 64, but node.exe is 32
1241
1241
if nodeexists {
1242
- os .Rename (nodepath , node32path ) // node.exe -> node32.exe
1242
+ utility .Rename (nodepath , node32path ) // node.exe -> node32.exe
1243
1243
}
1244
- os .Rename (node64path , nodepath ) // node64.exe -> node.exe
1244
+ utility .Rename (node64path , nodepath ) // node64.exe -> node.exe
1245
1245
}
1246
1246
1247
1247
status <- Status {Done : true }
0 commit comments