-
Notifications
You must be signed in to change notification settings - Fork 6
/
mix
executable file
·58 lines (48 loc) · 1.56 KB
/
mix
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
#!/bin/bash
set -e
# Ignored dirs
IGNORE_APPS=()
# Is command empty, print help
[ -z "$1" ] && mix help && exit
if [[ $1 =~ "--app" ]]
then
[ -z $2 ] && echo "usage: ./mix [--app app_name] [--(s)name name] args" && exit
[ ! -d "apps/$2" ] && echo "app $2 doesn't exists" && exit
[ -z $3 ] && echo "usage: ./mix [--app app_name] [--(s)name name] args" && exit
APP="$2"
shift 2
if [[ $1 =~ "--sname" ]]
then
[ -z $2 ] && echo "usage: ./mix [--app app_name] [--(s)name name] args" && exit
[ -z $3 ] && echo "usage: ./mix [--app app_name] [--(s)name name] args" && exit
SNAME="$2"
shift 2
echo "===== Running '$@' into '$APP' with sname '$SNAME' ====="
cd "apps/$APP"
elixir --sname $SNAME -S mix $@
elif [[ $1 =~ "--name" ]]
then
[ -z $2 ] && echo "usage: ./mix [--app app_name] [--(s)name name] args" && exit
[ -z $3 ] && echo "usage: ./mix [--app app_name] [--(s)name name] args" && exit
SNAME="$2"
shift 2
echo "===== Running '$@' into '$APP' with name '$SNAME' ====="
cd "apps/$APP"
elixir --name $SNAME -S mix $@
else
echo "===== Running '$@' into '$APP' ====="
cd "apps/$APP"
mix $@
fi
else
for APP in $(ls -d apps/*/ | sed 's,apps/,,' | sed 's/.$//')
do
[[ ${IGNORE_APPS[*]} =~ $APP ]] && continue;
[ ! -f "apps/$APP/mix.exs" ] && continue;
echo "===== Running '$@' into '$APP' ====="
cd "apps/$APP"
mix $@
cd - >/dev/null
echo
done
fi