nodeswitch 1.3.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 +2 -1
- package/bin/nodeswitch +1 -0
- package/bin/nodeswitch.sh +80 -0
- package/package.json +1 -1
- package/scripts/postinstall.cmd +4 -0
package/README.md
CHANGED
|
@@ -39,6 +39,7 @@ nodeswitch list
|
|
|
39
39
|
npm uninstall -g nodeswitch
|
|
40
40
|
|
|
41
41
|
*****
|
|
42
|
-
In
|
|
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 "$@"
|
|
@@ -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
package/scripts/postinstall.cmd
CHANGED
|
@@ -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 )
|