-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.sh
More file actions
54 lines (43 loc) · 1.14 KB
/
common.sh
File metadata and controls
54 lines (43 loc) · 1.14 KB
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
#!/bin/bash
# Begin Standard 'imports'
set -e
set -o pipefail
gray="\\e[37m"
blue="\\e[36m"
red="\\e[31m"
green="\\e[32m"
reset="\\e[0m"
info() { echo -e "${blue}INFO: $*${reset}"; }
error() { echo -e "${red}ERROR: $*${reset}"; }
debug() {
if [[ "${DEBUG}" == "true" ]]; then
echo -e "${gray}DEBUG: $*${reset}";
fi
}
success() { echo -e "${green}✔ $*${reset}"; }
fail() { echo -e "${red}✖ $*${reset}"; exit 1; }
## Enable debug mode.
enable_debug() {
if [[ "${DEBUG}" == "true" ]]; then
info "Enabling debug mode."
set -x
fi
}
# Execute code insight report script, saving its output and exit status code
report() {
set +e
stdout_report_log="/tmp/stdout_report.log"
output=""
echo "Generating report..."
node /dist/main.js "${stdout_log}" 1> "${stdout_report_log}" 2>>"${stderr_log}"
report_status=$?
output="$(<"${stdout_report_log}")"
output="Report succeed generated!!!${output}"
if [[ "$report_status" -ne 0 ]]; then
status=3 # custom exit code to indicate report error
output="Report Error:${stdout_report_log}$(<"${stderr_log}")"
fi
set -e
echo "${output}"
}
# End standard 'imports'