nodeswitch 1.1.0 → 1.3.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 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
+ ```
@@ -1,45 +1,69 @@
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
- curl -f https://nodejs.org/download/release/v%2 > nul 2>&1
10
- if %ERRORLEVEL% equ 0 (
11
- if "%1" == "add" (
12
- curl -s -o %AppData%\nodeswitch\%2.zip https://nodejs.org/download/release/v%2/node-v%2-win-x64.zip > nul
13
- tar -xf %AppData%\nodeswitch\%2.zip -C %AppData%\nodeswitch
14
- del %AppData%\nodeswitch\%2.zip
15
- move %AppData%\nodeswitch\node-v%2-win-x64 %AppData%\nodeswitch\%2 > nul
16
- ) else if "%1" == "remove" (
17
- if exist %AppData%\nodeswitch\%2 ( rmdir /s /q %AppData%\nodeswitch\%2 )
18
- ) else if "%1" == "use" (
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
- set "nodeswitchDefaultPATH=%PATH%"
22
- set "PATH=%PATH:C:\Program Files\nodejs\;=%;%AppData%\nodeswitch\%2"
22
+ if not "%PATH:C:\Program Files\nodejs\;=%" == "%PATH%" (
23
+ set "nodeswitchDefaultPATH=%PATH%"
24
+ set "nodeswitchTypePATH=1"
25
+ set "PATH=%PATH:C:\Program Files\nodejs\;=%;%AppData%\nodeswitch\%2"
26
+ ) else if not "%PATH:C:\Program Files\nodejs\=%" == "%PATH%" (
27
+ set "nodeswitchDefaultPATH=%PATH%"
28
+ set "nodeswitchTypePATH=2"
29
+ set "PATH=%PATH:C:\Program Files\nodejs\=%%AppData%\nodeswitch\%2"
30
+ ) else (
31
+ echo System environment variable Path doesn't include C:\Program Files\nodejs\
32
+ )
23
33
  ) else (
24
- set "PATH=%nodeswitchDefaultPATH:C:\Program Files\nodejs\;=%;%AppData%\nodeswitch\%2"
34
+ if "%nodeswitchTypePATH%" == "1" (
35
+ set "PATH=%nodeswitchDefaultPATH:C:\Program Files\nodejs\;=%;%AppData%\nodeswitch\%2"
36
+ ) else if "%nodeswitchTypePATH%" == "2" (
37
+ set "PATH=%nodeswitchDefaultPATH:C:\Program Files\nodejs\=%%AppData%\nodeswitch\%2"
38
+ ) else (
39
+ echo System environment variable Path doesn't include C:\Program Files\nodejs\
40
+ )
25
41
  )
26
42
  ) else (
27
43
  echo Node version not installed
28
44
  )
45
+ )
46
+ ) else if "%1" == "add" (
47
+ if not exist %AppData%\nodeswitch\%2 (
48
+ curl -f https://nodejs.org/download/release/v%2 > nul 2>&1
49
+ if %ERRORLEVEL% equ 0 (
50
+ curl -s -o %AppData%\nodeswitch\%2.zip https://nodejs.org/download/release/v%2/node-v%2-win-x64.zip > nul
51
+ tar -xf %AppData%\nodeswitch\%2.zip -C %AppData%\nodeswitch
52
+ del %AppData%\nodeswitch\%2.zip
53
+ move %AppData%\nodeswitch\node-v%2-win-x64 %AppData%\nodeswitch\%2 > nul
54
+ ) else (
55
+ echo Node version not found
56
+ )
29
57
  ) else (
30
- echo Incorrect command
58
+ echo Node version already added
31
59
  )
32
60
  ) else (
33
- echo Node version not found
61
+ echo Incorrect command
34
62
  )
35
63
  )
36
64
  ) else (
37
65
  if "%1" == "list" (
38
66
  dir /b %AppData%\nodeswitch
39
- ) else if "%1" == "default" (
40
- if defined nodeswitchDefaultPATH (
41
- set "PATH=%nodeswitchDefaultPATH%"
42
- )
43
67
  ) else (
44
68
  echo Incorrect command
45
69
  )
@@ -1,45 +1,74 @@
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
- curl -f https://nodejs.org/download/release/v$nodeswitch2ndParameter 2>&1>$null
10
- if ( $LASTEXITCODE -eq 0 ) {
11
- if ( $nodeswitch1stParameter -eq "add" ) {
12
- curl -s -o $env:AppData\nodeswitch\$nodeswitch2ndParameter.zip https://nodejs.org/download/release/v$nodeswitch2ndParameter/node-v$nodeswitch2ndParameter-win-x64.zip > $null
13
- tar -xf $env:AppData\nodeswitch\$nodeswitch2ndParameter.zip -C $env:AppData\nodeswitch
14
- del $env:AppData\nodeswitch\$nodeswitch2ndParameter.zip
15
- move $env:AppData\nodeswitch\node-v$nodeswitch2ndParameter-win-x64 $env:AppData\nodeswitch\$nodeswitch2ndParameter > nul
16
- } elseif ( $nodeswitch1stParameter -eq "remove" ) {
17
- if ( Test-Path -Path $env:AppData\nodeswitch\$nodeswitch2ndParameter ) { Remove-Item -Recurse $env:AppData\nodeswitch\$nodeswitch2ndParameter }
18
- } elseif ( $nodeswitch1stParameter -eq "use" ) {
19
- if ( $global:nodeswitchDefaultPATH -eq $null ) {
20
- $global:nodeswitchDefaultPATH = $env:Path
21
- $env:Path = $env:Path.split('C:\Program Files\nodejs\;')[0] + $env:Path.split('C:\Program Files\nodejs\;')[1] + ";$env:AppData\nodeswitch\$nodeswitch2ndParameter"
22
- } else {
23
- $env:Path = $global:nodeswitchDefaultPATH.split('C:\Program Files\nodejs\;')[0] + $global:nodeswitchDefaultPATH.split('C:\Program Files\nodejs\;')[1] + ";$env:AppData\nodeswitch\$nodeswitch2ndParameter"
24
- }
25
- } else {
26
- echo "Incorrect command"
27
- }
28
- } else {
29
- echo "Node version not found"
30
- }
31
- }
32
- } else {
33
- if ( $nodeswitch1stParameter -eq "list" ) {
34
- dir -n $env:AppData\nodeswitch
35
- } elseif ( $nodeswitch1stParameter -eq "default" ) {
36
- if ( $global:nodeswitchDefaultPATH -ne $null ) {
37
- $env:Path = $global:nodeswitchDefaultPATH
38
- }
39
- } else {
40
- echo "Incorrect command"
41
- }
42
- }
43
- } else {
44
- echo "Incorrect command"
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
+ if ( $env:path -like "*C:\Program Files\nodejs\;*" ) {
24
+ $global:nodeswitchDefaultPATH = $env:Path
25
+ $env:Path = cmd /c "echo %PATH:C:\Program Files\nodejs\;=%;$env:AppData\nodeswitch\$nodeswitch2ndParameter"
26
+ } elseif ( $env:path -like "*C:\Program Files\nodejs\*" ) {
27
+ $global:nodeswitchDefaultPATH = $env:Path
28
+ $env:Path = cmd /c "echo %PATH:C:\Program Files\nodejs\=%$env:AppData\nodeswitch\$nodeswitch2ndParameter"
29
+ } else {
30
+ echo "System environment variable Path doesn't include C:\Program Files\nodejs\"
31
+ }
32
+ } else {
33
+ if ( $global:nodeswitchDefaultPATH -like "*C:\Program Files\nodejs\;*" ) {
34
+ $env:Path = echo $global:nodeswitchDefaultPATH
35
+ $env:Path = cmd /c "echo %PATH:C:\Program Files\nodejs\;=%;$env:AppData\nodeswitch\$nodeswitch2ndParameter"
36
+ } elseif ( $global:nodeswitchDefaultPATH -like "*C:\Program Files\nodejs\*" ) {
37
+ $env:Path = echo $global:nodeswitchDefaultPATH
38
+ $env:Path = cmd /c "echo %PATH:C:\Program Files\nodejs\=%$env:AppData\nodeswitch\$nodeswitch2ndParameter"
39
+ } else {
40
+ echo "System environment variable Path doesn't include C:\Program Files\nodejs\"
41
+ }
42
+ }
43
+ } else {
44
+ echo "Node version not installed"
45
+ }
46
+ }
47
+ } elseif ( $nodeswitch1stParameter -eq "add" ) {
48
+ if ( -not ( Test-Path -Path $env:AppData\nodeswitch\$nodeswitch2ndParameter ) ) {
49
+ cmd /c "curl -f https://nodejs.org/download/release/v$nodeswitch2ndParameter > nul 2>&1"
50
+ if ( $LASTEXITCODE -eq 0 ) {
51
+ cmd /c "curl -s -o $env:AppData\nodeswitch\$nodeswitch2ndParameter.zip https://nodejs.org/download/release/v$nodeswitch2ndParameter/node-v$nodeswitch2ndParameter-win-x64.zip > nul"
52
+ tar -xf $env:AppData\nodeswitch\$nodeswitch2ndParameter.zip -C $env:AppData\nodeswitch
53
+ del $env:AppData\nodeswitch\$nodeswitch2ndParameter.zip
54
+ cmd /c "move $env:AppData\nodeswitch\node-v$nodeswitch2ndParameter-win-x64 $env:AppData\nodeswitch\$nodeswitch2ndParameter > nul"
55
+ } else {
56
+ echo "Node version not found"
57
+ }
58
+ } else {
59
+ echo "Node version already added"
60
+ }
61
+ } else {
62
+ echo "Incorrect command"
63
+ }
64
+ }
65
+ } else {
66
+ if ( $nodeswitch1stParameter -eq "list" ) {
67
+ dir -n $env:AppData\nodeswitch
68
+ } else {
69
+ echo "Incorrect command"
70
+ }
71
+ }
72
+ } else {
73
+ echo "Incorrect command"
45
74
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "nodeswitch",
3
- "version": "1.1.0",
4
- "description": "Node version switcher",
3
+ "version": "1.3.0",
4
+ "description": "Node version switcher for Microsoft Windows x64",
5
5
  "scripts": {
6
- "preinstall": "node scripts\\preinstall.js",
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
+ }