nodeswitch 1.2.0 → 1.4.1

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
@@ -39,6 +39,7 @@ nodeswitch list
39
39
  npm uninstall -g nodeswitch
40
40
 
41
41
  *****
42
- In your "C:\Users\YOUR_USERNAME\AppData\Roaming\npm" folder, delete 2 files: nodeswitch.cmd and nodeswitch.ps1
42
+ In the "C:\Users\YOUR_USERNAME\AppData\Roaming\npm" folder, delete 2 files: nodeswitch.cmd and nodeswitch.ps1
43
+ In the "C:\Users\YOUR_USERNAME\.bash_profile" file, remove the line [alias nodeswitch="source nodeswitch"]
43
44
  *****
44
45
  ```
package/bin/nodeswitch ADDED
@@ -0,0 +1 @@
1
+ source nodeswitch.sh "$@"
@@ -19,10 +19,25 @@ if not "%1" == "" (
19
19
  ) else (
20
20
  if exist %AppData%\nodeswitch\%2 (
21
21
  if not defined nodeswitchDefaultPATH (
22
- set "nodeswitchDefaultPATH=%PATH%"
23
- 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
+ )
24
33
  ) else (
25
- 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
+ )
26
41
  )
27
42
  ) else (
28
43
  echo Node version not installed
@@ -20,11 +20,25 @@ if ( $nodeswitch1stParameter -ne $null ) {
20
20
  } else {
21
21
  if ( Test-Path -Path $env:AppData\nodeswitch\$nodeswitch2ndParameter ) {
22
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"
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
+ }
25
32
  } else {
26
- $env:Path = echo $global:nodeswitchDefaultPATH
27
- $env:Path = cmd /c "echo %PATH:C:\Program Files\nodejs\;=%;$env:AppData\nodeswitch\$nodeswitch2ndParameter"
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
+ }
28
42
  }
29
43
  } else {
30
44
  echo "Node version not installed"
@@ -0,0 +1,80 @@
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodeswitch",
3
- "version": "1.2.0",
3
+ "version": "1.4.1",
4
4
  "description": "Node version switcher for Microsoft Windows x64",
5
5
  "scripts": {
6
6
  "preinstall": "node scripts/preinstall.js",
@@ -1,3 +1,7 @@
1
+ copy .\bin\nodeswitch %AppData%\npm
1
2
  copy .\bin\nodeswitch.cmd %AppData%\npm
2
3
  copy .\bin\nodeswitch.ps1 %AppData%\npm
4
+ copy .\bin\nodeswitch.sh %AppData%\npm
5
+ findstr /m "alias nodeswitch=" %userprofile%\.bash_profile > nul
6
+ if %errorlevel% == 1 ( echo alias nodeswitch="source nodeswitch" >> %userprofile%\.bash_profile )
3
7
  if not exist %AppData%\nodeswitch ( mkdir %AppData%\nodeswitch )