-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·56 lines (48 loc) · 1.11 KB
/
run.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
#!/bin/bash
set -e -o pipefail
install-elm(){
curl -L -o elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz
gunzip elm.gz
chmod +x elm
sudo mv elm /usr/local/bin/
}
install-elm-test-deps() {
if [ -z $(which elm) ]; then
echo "Installing Elm"
install-elm
else
echo "Elm already exists"
fi
if [ -z $(which elm-test) ]; then
echo "Installing elm-test"
npm install elm-test
else
echo "elm-test already exists"
export ELM_TEST_HOME=$(which elm-test)
fi
}
__elm-test() {
(
install-elm-test-deps
$ELM_TEST_HOME
)
}
validate_args() {
acceptable_args="$(declare -F | sed -n "s/declare -f __//p" | tr '\n' ' ')"
if [[ -z $1 ]]; then
echo "Must provide an argument"
echo -e "Available commands:\n$(declare -F | sed -n "s/declare -f __/ - /p")"
exit 1
fi
if [[ ! " $acceptable_args " =~ .*\ $1\ .* ]]; then
echo "Invalid argument: $1"
echo -e "Available commands:\n$(declare -F | sed -n "s/declare -f __/ - /p")"
exit 1
fi
}
CMD=${1:-}
shift || true
if validate_args ${CMD}; then
__${CMD}
exit 0
fi