nodeswitch 1.4.2 → 1.5.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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 alexsch01
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2023 alexsch01
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,45 @@
1
- # nodeswitch
2
-
3
- Node version switcher for Microsoft Windows x64
4
-
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 the "C:\Users\YOUR_USERNAME\AppData\Roaming\npm" folder, delete 4 files: nodeswitch, nodeswitch.cmd, nodeswitch.ps1, and nodeswitch.sh
43
- In the "C:\Users\YOUR_USERNAME\.bash_profile" file, remove the line [alias nodeswitch="source nodeswitch"]
44
- *****
45
- ```
1
+ # nodeswitch
2
+
3
+ Node version switcher for Microsoft Windows x64
4
+
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 the "C:\Users\YOUR_USERNAME\AppData\Roaming\npm" folder, delete 4 files: nodeswitch, nodeswitch.cmd, nodeswitch.ps1, and nodeswitch.sh
43
+ In the "C:\Users\YOUR_USERNAME\.bash_profile" file, remove the line [alias nodeswitch="source nodeswitch"]
44
+ *****
45
+ ```
package/bin/nodeswitch CHANGED
@@ -1 +1 @@
1
- source nodeswitch.sh "$@"
1
+ (return 0 2>/dev/null) && source nodeswitch.sh "$@" || echo "You need to relaunch Git Bash in order to use nodeswitch"
@@ -19,25 +19,10 @@ if not "%1" == "" (
19
19
  ) else (
20
20
  if exist %AppData%\nodeswitch\%2 (
21
21
  if not defined nodeswitchDefaultPATH (
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
- )
22
+ set "nodeswitchDefaultPATH=%PATH%"
23
+ set "PATH=%AppData%\nodeswitch\%2;%PATH%"
33
24
  ) else (
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
+ set "PATH=%AppData%\nodeswitch\%2;%nodeswitchDefaultPATH%"
41
26
  )
42
27
  ) else (
43
28
  echo Node version not installed
@@ -1,74 +1,59 @@
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"
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
+ 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 = "$env:AppData\nodeswitch\$nodeswitch2ndParameter;$env:Path"
25
+ } else {
26
+ $env:Path = "$env:AppData\nodeswitch\$nodeswitch2ndParameter;$global:nodeswitchDefaultPATH"
27
+ }
28
+ } else {
29
+ echo "Node version not installed"
30
+ }
31
+ }
32
+ } elseif ( $nodeswitch1stParameter -eq "add" ) {
33
+ if ( -not ( Test-Path -Path $env:AppData\nodeswitch\$nodeswitch2ndParameter ) ) {
34
+ cmd /c "curl -f https://nodejs.org/download/release/v$nodeswitch2ndParameter > nul 2>&1"
35
+ if ( $LASTEXITCODE -eq 0 ) {
36
+ cmd /c "curl -s -o $env:AppData\nodeswitch\$nodeswitch2ndParameter.zip https://nodejs.org/download/release/v$nodeswitch2ndParameter/node-v$nodeswitch2ndParameter-win-x64.zip > nul"
37
+ tar -xf $env:AppData\nodeswitch\$nodeswitch2ndParameter.zip -C $env:AppData\nodeswitch
38
+ del $env:AppData\nodeswitch\$nodeswitch2ndParameter.zip
39
+ cmd /c "move $env:AppData\nodeswitch\node-v$nodeswitch2ndParameter-win-x64 $env:AppData\nodeswitch\$nodeswitch2ndParameter > nul"
40
+ } else {
41
+ echo "Node version not found"
42
+ }
43
+ } else {
44
+ echo "Node version already added"
45
+ }
46
+ } else {
47
+ echo "Incorrect command"
48
+ }
49
+ }
50
+ } else {
51
+ if ( $nodeswitch1stParameter -eq "list" ) {
52
+ dir -n $env:AppData\nodeswitch
53
+ } else {
54
+ echo "Incorrect command"
55
+ }
56
+ }
57
+ } else {
58
+ echo "Incorrect command"
59
+ }
package/bin/nodeswitch.sh CHANGED
@@ -1,80 +1,63 @@
1
- if [ "$#" = "2" ]
2
- then
3
- if [ "$1" = "remove" ]
4
- then
5
- if [ -d "$APPDATA/nodeswitch/$2" ]
6
- then
7
- rm -rf $APPDATA/nodeswitch/$2
8
- else
9
- echo "Node version not installed"
10
- fi
11
- elif [ "$1" = "use" ]
12
- then
13
- if [ "$2" = "default" ]
14
- then
15
- if [ ! -z "$nodeswitchDefaultPATH" ]
16
- then
17
- export PATH=$nodeswitchDefaultPATH
18
- fi
19
- else
20
- if [ -d "$APPDATA/nodeswitch/$2" ]
21
- then
22
- if [ -z "$nodeswitchDefaultPATH" ]
23
- then
24
- if [ ! "${PATH//\/c\/Program Files\/nodejs:/}" == "$PATH" ]
25
- then
26
- export nodeswitchDefaultPATH=$PATH
27
- export PATH=${PATH//\/c\/Program Files\/nodejs:/}:$APPDATA/nodeswitch/$2
28
- elif [ ! "${PATH//\/c\/Program Files\/nodejs/}" == "$PATH" ]
29
- then
30
- export nodeswitchDefaultPATH=$PATH
31
- export PATH=${PATH//\/c\/Program Files\/nodejs/}$APPDATA/nodeswitch/$2
32
- else
33
- echo "System environment variable Path doesn't include /c/Program Files/nodejs"
34
- fi
35
- else
36
- if [ ! "${nodeswitchDefaultPATH//\/c\/Program Files\/nodejs:/}" == "$nodeswitchDefaultPATH" ]
37
- then
38
- export PATH=${nodeswitchDefaultPATH//\/c\/Program Files\/nodejs:/}:$APPDATA/nodeswitch/$2
39
- elif [ ! "${nodeswitchDefaultPATH//\/c\/Program Files\/nodejs/}" == "$nodeswitchDefaultPATH" ]
40
- then
41
- export PATH=${nodeswitchDefaultPATH//\/c\/Program Files\/nodejs/}$APPDATA/nodeswitch/$2
42
- else
43
- echo "System environment variable Path doesn't include /c/Program Files/nodejs"
44
- fi
45
- fi
46
- else
47
- echo "Node version not installed"
48
- fi
49
- fi
50
- elif [ "$1" = "add" ]
51
- then
52
- if [ ! -d "$APPDATA/nodeswitch/$2" ]
53
- then
54
- curl -f https://nodejs.org/download/release/v$2 &>/dev/null
55
- if [ $? -eq 0 ]
56
- then
57
- curl -s -o $APPDATA/nodeswitch/$2.zip https://nodejs.org/download/release/v$2/node-v$2-win-x64.zip > /dev/null
58
- unzip -d $APPDATA/nodeswitch -o $APPDATA/nodeswitch/$2.zip > /dev/null
59
- rm $APPDATA/nodeswitch/$2.zip
60
- mv $APPDATA/nodeswitch/node-v$2-win-x64 $APPDATA/nodeswitch/$2 > /dev/null
61
- else
62
- echo "Node version not found"
63
- fi
64
- else
65
- echo "Node version already added"
66
- fi
67
- else
68
- echo "Incorrect command"
69
- fi
70
- elif [ "$#" = "1" ]
71
- then
72
- if [ "$1" = "list" ]
73
- then
74
- ls -1 $APPDATA/nodeswitch
75
- else
76
- echo "Incorrect command"
77
- fi
78
- else
79
- echo "Incorrect command"
80
- fi
1
+ if [ "$#" = "2" ]
2
+ then
3
+ if [ "$1" = "remove" ]
4
+ then
5
+ if [ -d "$APPDATA/nodeswitch/$2" ]
6
+ then
7
+ rm -rf $APPDATA/nodeswitch/$2
8
+ else
9
+ echo "Node version not installed"
10
+ fi
11
+ elif [ "$1" = "use" ]
12
+ then
13
+ if [ "$2" = "default" ]
14
+ then
15
+ if [ ! -z "$nodeswitchDefaultPATH" ]
16
+ then
17
+ export PATH=$nodeswitchDefaultPATH
18
+ fi
19
+ else
20
+ if [ -d "$APPDATA/nodeswitch/$2" ]
21
+ then
22
+ if [ -z "$nodeswitchDefaultPATH" ]
23
+ then
24
+ export nodeswitchDefaultPATH=$PATH
25
+ export PATH=$APPDATA/nodeswitch/$2:$PATH
26
+ else
27
+ export PATH=$APPDATA/nodeswitch/$2:$nodeswitchDefaultPATH
28
+ fi
29
+ else
30
+ echo "Node version not installed"
31
+ fi
32
+ fi
33
+ elif [ "$1" = "add" ]
34
+ then
35
+ if [ ! -d "$APPDATA/nodeswitch/$2" ]
36
+ then
37
+ curl -f https://nodejs.org/download/release/v$2 &>/dev/null
38
+ if [ $? -eq 0 ]
39
+ then
40
+ curl -s -o $APPDATA/nodeswitch/$2.zip https://nodejs.org/download/release/v$2/node-v$2-win-x64.zip > /dev/null
41
+ unzip -d $APPDATA/nodeswitch -o $APPDATA/nodeswitch/$2.zip > /dev/null
42
+ rm $APPDATA/nodeswitch/$2.zip
43
+ mv $APPDATA/nodeswitch/node-v$2-win-x64 $APPDATA/nodeswitch/$2 > /dev/null
44
+ else
45
+ echo "Node version not found"
46
+ fi
47
+ else
48
+ echo "Node version already added"
49
+ fi
50
+ else
51
+ echo "Incorrect command"
52
+ fi
53
+ elif [ "$#" = "1" ]
54
+ then
55
+ if [ "$1" = "list" ]
56
+ then
57
+ ls -1 $APPDATA/nodeswitch
58
+ else
59
+ echo "Incorrect command"
60
+ fi
61
+ else
62
+ echo "Incorrect command"
63
+ fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodeswitch",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "description": "Node version switcher for Microsoft Windows x64",
5
5
  "scripts": {
6
6
  "preinstall": "node scripts/preinstall.js",