-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.sh
112 lines (105 loc) · 3.04 KB
/
node.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
#Step: DANCI Setup
echo "$ nvm -v"
. /script/nvm/nvm.sh && nvm --version
#if [ $LANGUAGE_VERSION -eq 4 ] || [ $LANGUAGE_VERSION -eq 5 ] || [ $LANGUAGE_VERSION -eq 6 ];
#then
# echo "$ nvm use $LANGUAGE_VERSION"
# . /script/nvm/nvm.sh && nvm use $LANGUAGE_VERSION
#else
# echo "$ nvm install $LANGUAGE_VERSION"
# . /script/nvm/nvm.sh && nvm install $LANGUAGE_VERSION
#fi
echo "$ nvm install $LANGUAGE_VERSION"
. /script/nvm/nvm.sh && nvm install $LANGUAGE_VERSION
if [ $? -eq 0 ]
then
node_version=`node -v`
npm_version=`npm -v`
echo "nvm install $LANGUAGE_VERSION exited with 0"
echo "DANCI_STEP_SUMMARY_Installed Node $node_version, NPM v$npm_version"
echo "DANCI_STEP_STATUS_SUCCESS"
else
echo "DANCI_ERROR_Error running nvm install $LANGUAGE_VERSION" >&2
echo "DANCI_STEP_SUMMARY_Error running nvm install $LANGUAGE_VERSION"
echo "DANCI_STEP_STATUS_FAILURE"
exit
fi
echo "$ node -v"
node -v
echo "$ npm -v"
npm -v
#Step: Install
if [ -z ${DANCI_INSTALL+x} ];
then
echo "DANCI_NEXT_STEP_$ npm install"
echo "$ npm install"
npm install
if [ $? -eq 0 ]
then
echo "npm install exited with 0"
echo "DANCI_STEP_SUMMARY_The command \"npm install\" exited with 0"
echo "DANCI_STEP_STATUS_SUCCESS"
else
echo "DANCI_ERROR_Error running npm install" >&2
echo "DANCI_STEP_SUMMARY_Error running npm install"
echo "DANCI_STEP_STATUS_FAILURE"
exit
fi
else
IFS=',' read -ra install_arr <<< "$DANCI_INSTALL"
for cmd in "${install_arr[@]}";
do
echo "DANCI_NEXT_STEP_$ $cmd"
echo "$ $cmd"
$cmd
if [ $? -eq 0 ]
then
echo "$cmd exited with 0"
echo "DANCI_STEP_SUMMARY_The command \"$cmd\" exited with 0"
echo "DANCI_STEP_STATUS_SUCCESS"
else
echo "DANCI_ERROR_Error running $cmd" >&2
echo "DANCI_STEP_SUMMARY_Error running $cmd"
echo "DANCI_STEP_STATUS_FAILURE"
exit
fi
done
fi
#Step: Test
if [ -z ${DANCI_TEST+x} ];
then
echo "DANCI_NEXT_STEP_$ npm test"
echo "$ npm test"
npm test
if [ $? -eq 0 ]
then
echo "npm test exited with 0"
echo "DANCI_STEP_SUMMARY_The command \"npm test\" exited with 0"
echo "DANCI_STEP_STATUS_SUCCESS"
else
echo "DANCI_ERROR_Error running npm test" >&2
echo "DANCI_STEP_SUMMARY_Error running npm test"
echo "DANCI_STEP_STATUS_FAILURE"
exit
fi
else
IFS=',' read -ra test_arr <<< "$DANCI_TEST"
for cmd in "${test_arr[@]}";
do
echo "DANCI_NEXT_STEP_$ $cmd"
echo "$ $cmd"
$cmd
if [ $? -eq 0 ]
then
echo "$cmd exited with 0"
echo "DANCI_STEP_SUMMARY_The command \"$cmd\" exited with 0"
echo "DANCI_STEP_STATUS_SUCCESS"
else
echo "DANCI_ERROR_Error running $cmd" >&2
echo "DANCI_STEP_SUMMARY_Error running $cmd"
echo "DANCI_STEP_STATUS_FAILURE"
exit
fi
done
fi