-
Notifications
You must be signed in to change notification settings - Fork 9
/
eru-new.sh
executable file
·76 lines (63 loc) · 1.78 KB
/
eru-new.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
#!/usr/bin/env bash
#
################################################################################
#
# Of the theme that I have declared to you, I will now that ye make in harmony
# together a Great Music. And since I have kindled you with the Flame
# Imperishable, ye shall show forth your powers in adorning this theme, each
# with his own thoughts and devices, if he will. But I win sit and hearken, and
# be glad that through you great beauty has been wakened into song.
#
# John Ronald Reuel Tolkien (c)
#
################################################################################
set -e
function silence {
local output=
if ! output=$(eval "$@" 2>&1); then
echo "$output"
exit 1
fi
}
#
# Fetching the notes
#
export XDG_CONFIG_HOME=$HOME/.config
env_https=https://github.com/d12frosted/environment
[email protected]:d12frosted/environment.git
if [ -d "$XDG_CONFIG_HOME" ] && [ ! -d "$XDG_CONFIG_HOME/.git" ]; then
cd "$XDG_CONFIG_HOME" && {
git init
# clone via HTTPS, as most likely SSH is not yet available or configured
git remote add origin $env_https
git fetch
git reset --hard origin/master
}
fi
if [ ! -d "$XDG_CONFIG_HOME/.git" ]; then
# clone via HTTPS, as most likely SSH is not yet available or configured
git clone $env_https "$XDG_CONFIG_HOME"
fi
cd "$XDG_CONFIG_HOME" && {
git remote set-url origin $env_ssh
}
#
# Haskell is the language of Eru.
#
if command -v stack >/dev/null 2>&1; then
silence stack upgrade
else
curl -sSL https://get.haskellstack.org/ | sh
fi
#
# Now start the Great Music
#
cd "$XDG_CONFIG_HOME/melkor" && {
silence stack setup --allow-different-user
silence stack build --allow-different-user
if [ "$1" = test ]; then
stack test
else
stack exec --allow-different-user -- melkor "$@"
fi
}