forked from electrode-io/electrode-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
envalidate.sh
executable file
·100 lines (80 loc) · 2.26 KB
/
envalidate.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
#!/bin/bash
# https://gist.github.com/JamieMason/4761049
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1
# set to 0 if not found
type $1 >/dev/null 2>&1 || { local return_=0; }
# return value
echo "$return_"
}
function print_version {
local version="--version"
if [ ! -z "$2" ]; then
version=$2
fi
if [ $(program_is_installed $1) == 1 ]; then
printf "$1 $version"
fi
}
# display a message in red with a cross by it
# example
# echo echo_fail "No"
function echo_fail {
# echo first argument in red
printf "\e[31m✘ ${1}"
# reset colours back to normal
echo "\033[0m"
}
# display a message in green with a tick by it
# example
# echo echo_fail "Yes"
function echo_pass {
# echo first argument in green
printf "\e[32m✔ ${1}"
# reset colours back to normal
echo "\033[0m"
}
# echo pass or fail
# example
# echo echo_if 1 "Passed"
# echo echo_if 0 "Failed"
function echo_if {
if [ $1 == 1 ]; then
echo_pass "$2"
else
echo_fail "$2"
fi
}
# ============================================== Functions
normal=$(tput sgr0)
bright=$(tput bold)
# command line programs
printf "${bright} --- Node.js 10 or later ---${normal}\n"
echo "node $(echo_if $(program_is_installed node))"
$(print_version node)
printf "\n"
printf "${bright} --- npm or Yarn ---${normal}\n"
echo "npm $(echo_if $(program_is_installed npm))"
$(print_version npm)
printf "\n"
echo "yarn $(echo_if $(program_is_installed yarn))"
$(print_version yarn)
printf "\n"
printf "${bright} --- Xcode 10 or later for iOS apps ---${normal}\n"
echo "Xcode $(echo_if $(program_is_installed xcodebuild))"
$(print_version xcodebuild -version)
printf "\n"
printf "${bright} --- Android Studio for Android apps ---${normal}\n"
echo "Android $(echo_if $(program_is_installed $ANDROID_HOME/tools/bin/sdkmanager))"
if [ $(program_is_installed $ANDROID_HOME/tools/bin/sdkmanager) == 0 ]; then
echo $(echo_if 0 "Please make sure to install android sdk and set ANDROID_HOME in env variables." )
fi
printf "\n"
printf "${BRIGHT} --- Electrode Native ---${normal}\n"
echo "ern $(echo_if $(program_is_installed ern))"
$(print_version ern)
printf "\n"