-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
57 lines (43 loc) · 1.09 KB
/
entrypoint.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
#!/bin/bash
# Add gems, add/configure guard-nanoc, run the command
if_missing_guard_nanoc ()
{
# or, is commented out
[ -z "$(sed -n '/group :nanoc do/,/end/p' < Gemfile | grep -E '^[^#]+guard-nanoc' )" ]
}
add_guard_nanoc ()
{
# add to Gemfile
sed -i '$a \\ngroup :nanoc do\n gem \x27guard-nanoc\x27\nend' Gemfile
}
create_guard_file ()
{
bundle exec guard init nanoc
}
start_nanoc_with_guard ()
{
"bundle exec nanoc live"
}
# expecting that app root directory is current directory
[ -z "$(ls $(pwd) )" ] && {
echo "Did you forget to mount a volume with your project in it?" >&2
exit 1
}
# Install needed gems
bundle check &> /dev/null || {
bundle check | sed '$d' >&2
echo "Installing missing gems..." >&2
bundle install
}
# guard-nanoc gem
if_missing_guard_nanoc && {
echo "No valid 'guard-nanoc' entry found in Gemfile." >&2
echo "Adding 'guard-nanoc' to Gemfile." >&2
add_guard_nanoc
}
# Add Guardfile, if none
[ -f ./Guardfile ] || {
echo "No guard file found. Creating one." >&2
create_guard_file
}
exec bundle exec nanoc "$@"