nodeswitch 1.6.1 → 1.6.2
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/bin/nodeswitch.sh +51 -44
- package/package.json +1 -1
package/bin/nodeswitch.sh
CHANGED
|
@@ -1,62 +1,69 @@
|
|
|
1
|
-
if [ "
|
|
1
|
+
if [ "$1" != "" ]
|
|
2
2
|
then
|
|
3
|
-
if [ "$
|
|
3
|
+
if [ "$2" != "" ]
|
|
4
4
|
then
|
|
5
|
-
if [
|
|
5
|
+
if [ "$3" != "" ]
|
|
6
6
|
then
|
|
7
|
-
|
|
7
|
+
echo "Incorrect command"
|
|
8
8
|
else
|
|
9
|
-
|
|
10
|
-
fi
|
|
11
|
-
elif [ "$1" = "use" ]
|
|
12
|
-
then
|
|
13
|
-
if [ "$2" = "default" ]
|
|
14
|
-
then
|
|
15
|
-
if [ ! -z "$nodeswitchDefaultPATH" ]
|
|
9
|
+
if [ "$1" = "remove" ]
|
|
16
10
|
then
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
if [ -d "$APPDATA/nodeswitch/$2" ]
|
|
12
|
+
then
|
|
13
|
+
rm -rf $APPDATA/nodeswitch/$2
|
|
14
|
+
else
|
|
15
|
+
echo "Node version not installed"
|
|
16
|
+
fi
|
|
17
|
+
elif [ "$1" = "use" ]
|
|
18
|
+
then
|
|
19
|
+
if [ "$2" = "default" ]
|
|
20
|
+
then
|
|
21
|
+
if [ ! -z "$nodeswitchDefaultPATH" ]
|
|
22
|
+
then
|
|
23
|
+
export PATH=$nodeswitchDefaultPATH
|
|
24
|
+
fi
|
|
25
|
+
else
|
|
26
|
+
if [ -d "$APPDATA/nodeswitch/$2" ]
|
|
27
|
+
then
|
|
28
|
+
if [ -z "$nodeswitchDefaultPATH" ]
|
|
29
|
+
then
|
|
30
|
+
export nodeswitchDefaultPATH=$PATH
|
|
31
|
+
export PATH=$APPDATA/nodeswitch/$2:$PATH
|
|
32
|
+
else
|
|
33
|
+
export PATH=$APPDATA/nodeswitch/$2:$nodeswitchDefaultPATH
|
|
34
|
+
fi
|
|
35
|
+
else
|
|
36
|
+
echo "Node version not installed"
|
|
37
|
+
fi
|
|
38
|
+
fi
|
|
39
|
+
elif [ "$1" = "add" ]
|
|
21
40
|
then
|
|
22
|
-
if [ -
|
|
41
|
+
if [ ! -d "$APPDATA/nodeswitch/$2" ]
|
|
23
42
|
then
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
curl -f https://nodejs.org/download/release/v$2 &>/dev/null
|
|
44
|
+
if [ $? -eq 0 ]
|
|
45
|
+
then
|
|
46
|
+
curl -s -o $APPDATA/nodeswitch/$2.zip https://nodejs.org/download/release/v$2/node-v$2-win-x64.zip > /dev/null
|
|
47
|
+
unzip -d $APPDATA/nodeswitch -o $APPDATA/nodeswitch/$2.zip > /dev/null
|
|
48
|
+
rm $APPDATA/nodeswitch/$2.zip
|
|
49
|
+
mv $APPDATA/nodeswitch/node-v$2-win-x64 $APPDATA/nodeswitch/$2 > /dev/null
|
|
50
|
+
else
|
|
51
|
+
echo "Node version not found"
|
|
52
|
+
fi
|
|
26
53
|
else
|
|
27
|
-
|
|
54
|
+
echo "Node version already added"
|
|
28
55
|
fi
|
|
29
56
|
else
|
|
30
|
-
echo "
|
|
57
|
+
echo "Incorrect command"
|
|
31
58
|
fi
|
|
32
59
|
fi
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if [ ! -d "$APPDATA/nodeswitch/$2" ]
|
|
60
|
+
else
|
|
61
|
+
if [ "$1" = "list" ]
|
|
36
62
|
then
|
|
37
|
-
|
|
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
|
|
63
|
+
dir -1 $APPDATA/nodeswitch
|
|
47
64
|
else
|
|
48
|
-
echo "
|
|
65
|
+
echo "Incorrect command"
|
|
49
66
|
fi
|
|
50
|
-
else
|
|
51
|
-
echo "Incorrect command"
|
|
52
|
-
fi
|
|
53
|
-
elif [ "$#" = "1" ]
|
|
54
|
-
then
|
|
55
|
-
if [ "$1" = "list" ]
|
|
56
|
-
then
|
|
57
|
-
dir $APPDATA/nodeswitch
|
|
58
|
-
else
|
|
59
|
-
echo "Incorrect command"
|
|
60
67
|
fi
|
|
61
68
|
else
|
|
62
69
|
echo "Incorrect command"
|