nodeswitch 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -2
- package/bin/nodeswitch.cmd +26 -17
- package/bin/nodeswitch.ps1 +59 -44
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# nodeswitch
|
|
2
2
|
|
|
3
|
-
Node version switcher
|
|
3
|
+
Node version switcher for Microsoft Windows x64
|
|
4
4
|
|
|
5
|
-
https://github.com/alexsch01/nodeswitch
|
|
5
|
+
https://github.com/alexsch01/nodeswitch
|
|
6
|
+
|
|
7
|
+
<br>
|
|
8
|
+
|
|
9
|
+
#### How To Install
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm install -g nodeswitch
|
|
13
|
+
|
|
14
|
+
*****
|
|
15
|
+
Node versions installed by this tool are in the "C:\Users\YOUR_USERNAME\AppData\Roaming\nodeswitch" folder
|
|
16
|
+
*****
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
#### Examples
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
nodeswitch add 12.16.3
|
|
23
|
+
nodeswitch add 18.13.0
|
|
24
|
+
|
|
25
|
+
nodeswitch remove 12.16.3
|
|
26
|
+
nodeswitch remove 18.13.0
|
|
27
|
+
|
|
28
|
+
nodeswitch use 12.16.3
|
|
29
|
+
nodeswitch use 18.13.0
|
|
30
|
+
|
|
31
|
+
nodeswitch use default
|
|
32
|
+
|
|
33
|
+
nodeswitch list
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
#### How To Uninstall
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
npm uninstall -g nodeswitch
|
|
40
|
+
|
|
41
|
+
*****
|
|
42
|
+
In your "C:\Users\YOUR_USERNAME\AppData\Roaming\npm" folder, delete 2 files: nodeswitch.cmd and nodeswitch.ps1
|
|
43
|
+
*****
|
|
44
|
+
```
|
package/bin/nodeswitch.cmd
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
@echo off
|
|
2
|
-
@REM cmd /c "npm pack && npm i -g nodeswitch-1.0.0.tgz && del nodeswitch-1.0.0.tgz"
|
|
3
2
|
|
|
4
3
|
if not "%1" == "" (
|
|
5
4
|
if not "%2" == "" (
|
|
6
5
|
if not "%3" == "" (
|
|
7
6
|
echo Incorrect command
|
|
8
7
|
) else (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if
|
|
18
|
-
|
|
8
|
+
if "%1" == "remove" (
|
|
9
|
+
if exist %AppData%\nodeswitch\%2 (
|
|
10
|
+
rmdir /s /q %AppData%\nodeswitch\%2
|
|
11
|
+
) else (
|
|
12
|
+
echo Node version not installed
|
|
13
|
+
)
|
|
14
|
+
) else if "%1" == "use" (
|
|
15
|
+
if "%2" == "default" (
|
|
16
|
+
if defined nodeswitchDefaultPATH (
|
|
17
|
+
set "PATH=%nodeswitchDefaultPATH%"
|
|
18
|
+
)
|
|
19
|
+
) else (
|
|
19
20
|
if exist %AppData%\nodeswitch\%2 (
|
|
20
21
|
if not defined nodeswitchDefaultPATH (
|
|
21
22
|
set "nodeswitchDefaultPATH=%PATH%"
|
|
@@ -26,20 +27,28 @@ if not "%1" == "" (
|
|
|
26
27
|
) else (
|
|
27
28
|
echo Node version not installed
|
|
28
29
|
)
|
|
30
|
+
)
|
|
31
|
+
) else if "%1" == "add" (
|
|
32
|
+
if not exist %AppData%\nodeswitch\%2 (
|
|
33
|
+
curl -f https://nodejs.org/download/release/v%2 > nul 2>&1
|
|
34
|
+
if %ERRORLEVEL% equ 0 (
|
|
35
|
+
curl -s -o %AppData%\nodeswitch\%2.zip https://nodejs.org/download/release/v%2/node-v%2-win-x64.zip > nul
|
|
36
|
+
tar -xf %AppData%\nodeswitch\%2.zip -C %AppData%\nodeswitch
|
|
37
|
+
del %AppData%\nodeswitch\%2.zip
|
|
38
|
+
move %AppData%\nodeswitch\node-v%2-win-x64 %AppData%\nodeswitch\%2 > nul
|
|
39
|
+
) else (
|
|
40
|
+
echo Node version not found
|
|
41
|
+
)
|
|
29
42
|
) else (
|
|
30
|
-
echo
|
|
43
|
+
echo Node version already added
|
|
31
44
|
)
|
|
32
45
|
) else (
|
|
33
|
-
echo
|
|
46
|
+
echo Incorrect command
|
|
34
47
|
)
|
|
35
48
|
)
|
|
36
49
|
) else (
|
|
37
50
|
if "%1" == "list" (
|
|
38
51
|
dir /b %AppData%\nodeswitch
|
|
39
|
-
) else if "%1" == "default" (
|
|
40
|
-
if defined nodeswitchDefaultPATH (
|
|
41
|
-
set "PATH=%nodeswitchDefaultPATH%"
|
|
42
|
-
)
|
|
43
52
|
) else (
|
|
44
53
|
echo Incorrect command
|
|
45
54
|
)
|
package/bin/nodeswitch.ps1
CHANGED
|
@@ -1,45 +1,60 @@
|
|
|
1
|
-
$nodeswitch1stParameter = $args[0]
|
|
2
|
-
$nodeswitch2ndParameter = $args[1]
|
|
3
|
-
|
|
4
|
-
if ( $nodeswitch1stParameter -ne $null ) {
|
|
5
|
-
if ( $nodeswitch2ndParameter -ne $null ) {
|
|
6
|
-
if ( $args[2] -ne $null ) {
|
|
7
|
-
echo "Incorrect command"
|
|
8
|
-
} else {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
1
|
+
$nodeswitch1stParameter = $args[0]
|
|
2
|
+
$nodeswitch2ndParameter = $args[1]
|
|
3
|
+
|
|
4
|
+
if ( $nodeswitch1stParameter -ne $null ) {
|
|
5
|
+
if ( $nodeswitch2ndParameter -ne $null ) {
|
|
6
|
+
if ( $args[2] -ne $null ) {
|
|
7
|
+
echo "Incorrect command"
|
|
8
|
+
} else {
|
|
9
|
+
if ( $nodeswitch1stParameter -eq "remove" ) {
|
|
10
|
+
if ( Test-Path -Path $env:AppData\nodeswitch\$nodeswitch2ndParameter ) {
|
|
11
|
+
Remove-Item -Recurse $env:AppData\nodeswitch\$nodeswitch2ndParameter
|
|
12
|
+
} else {
|
|
13
|
+
echo "Node version not installed"
|
|
14
|
+
}
|
|
15
|
+
} elseif ( $nodeswitch1stParameter -eq "use" ) {
|
|
16
|
+
if ( $nodeswitch2ndParameter -eq "default" ) {
|
|
17
|
+
if ( $global:nodeswitchDefaultPATH -ne $null ) {
|
|
18
|
+
$env:Path = $global:nodeswitchDefaultPATH
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
if ( Test-Path -Path $env:AppData\nodeswitch\$nodeswitch2ndParameter ) {
|
|
22
|
+
if ( $global:nodeswitchDefaultPATH -eq $null ) {
|
|
23
|
+
$global:nodeswitchDefaultPATH = $env:Path
|
|
24
|
+
$env:Path = cmd /c "echo %PATH:C:\Program Files\nodejs\;=%;$env:AppData\nodeswitch\$nodeswitch2ndParameter"
|
|
25
|
+
} else {
|
|
26
|
+
$env:Path = echo $global:nodeswitchDefaultPATH
|
|
27
|
+
$env:Path = cmd /c "echo %PATH:C:\Program Files\nodejs\;=%;$env:AppData\nodeswitch\$nodeswitch2ndParameter"
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
echo "Node version not installed"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
} elseif ( $nodeswitch1stParameter -eq "add" ) {
|
|
34
|
+
if ( -not ( Test-Path -Path $env:AppData\nodeswitch\$nodeswitch2ndParameter ) ) {
|
|
35
|
+
cmd /c "curl -f https://nodejs.org/download/release/v$nodeswitch2ndParameter > nul 2>&1"
|
|
36
|
+
if ( $LASTEXITCODE -eq 0 ) {
|
|
37
|
+
cmd /c "curl -s -o $env:AppData\nodeswitch\$nodeswitch2ndParameter.zip https://nodejs.org/download/release/v$nodeswitch2ndParameter/node-v$nodeswitch2ndParameter-win-x64.zip > nul"
|
|
38
|
+
tar -xf $env:AppData\nodeswitch\$nodeswitch2ndParameter.zip -C $env:AppData\nodeswitch
|
|
39
|
+
del $env:AppData\nodeswitch\$nodeswitch2ndParameter.zip
|
|
40
|
+
cmd /c "move $env:AppData\nodeswitch\node-v$nodeswitch2ndParameter-win-x64 $env:AppData\nodeswitch\$nodeswitch2ndParameter > nul"
|
|
41
|
+
} else {
|
|
42
|
+
echo "Node version not found"
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
echo "Node version already added"
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
echo "Incorrect command"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
if ( $nodeswitch1stParameter -eq "list" ) {
|
|
53
|
+
dir -n $env:AppData\nodeswitch
|
|
54
|
+
} else {
|
|
55
|
+
echo "Incorrect command"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
echo "Incorrect command"
|
|
45
60
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodeswitch",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Node version switcher",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Node version switcher for Microsoft Windows x64",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"preinstall": "node scripts
|
|
6
|
+
"preinstall": "node scripts/preinstall.js",
|
|
7
7
|
"postinstall": "scripts\\postinstall.cmd"
|
|
8
8
|
},
|
|
9
9
|
"author": "alexsch01",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"keywords": [
|
|
12
12
|
"node",
|
|
13
13
|
"version",
|
|
14
|
-
"switcher"
|
|
14
|
+
"switcher",
|
|
15
|
+
"microsoft",
|
|
16
|
+
"windows",
|
|
17
|
+
"x64"
|
|
15
18
|
]
|
|
16
|
-
}
|
|
19
|
+
}
|