forked from concord-consortium/lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Guardfile
executable file
·172 lines (138 loc) · 4.84 KB
/
Guardfile
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
ignore %r{(bin|node_modules)}
# FireSass allows Firebug to display the original Sass filename
# and line number of Sass-generated CSS styles
# https://github.com/nex3/firesass
FIRESASS = false
require "./script/setup.rb"
def command(cmd)
puts cmd
system(cmd)
end
ENV['LAB_DEVELOPMENT'] = "true"
command("make")
puts <<HEREDOC
ready ...
HEREDOC
def delete_css
puts "re-generating all css resources ..."
command("find public \! -path 'public/vendor*' -name '*.css' | xargs rm -f")
end
group :build do
guard 'sass', :input => 'src/examples', :output => 'public/examples', :all_on_start => false, :load_paths => ['src']
guard 'sass', :input => 'src/doc', :output => 'public/doc', :all_on_start => false, :load_paths => ['src']
guard 'coffeescript', :input => 'src/examples', :output => 'public/examples', :all_on_start => false
guard 'coffeescript', :input => 'src/doc', :output => 'public/doc', :all_on_start => false
guard 'haml', :input => 'src', :output => 'public', :all_on_start => false do
watch %r{^src.+(\.html\.haml)}
end
guard 'haml', :input => 'test', :output => 'test', :all_on_start => false do
watch %r{^test.+(\.html\.haml)}
end
guard 'shell' do
watch(/(script\/(generate.*|setup.rb))|(config\/config\.yml)/) do |match|
puts "re-generating version and config information ..."
delete_css
command("make")
end
watch(/(^src\/lab\/.+)|(^src\/modules\/.+)/) do |match|
file = match[0]
unless file =~ /(lab.config.js)|(lab.version.js)/
puts "***" + file
puts "re-generating javascript libraries and css resources for these libraries ..."
command("make src")
end
end
watch(/(^src\/helpers\/.+)/) do |match|
file = match[0]
case match[0]
when /\/md2d\/mml-parser/
if system("./node_modules/.bin/vows --isolate test/vows/mml-conversions/conversion-test.js")
puts "*** mml conversion tests passed, mml conversions started ..."
command("make convert-all-mml")
else
puts "*** error running mml conversion tests, mml conversions not started."
end
when /\/md2d\/(mw-batch-converter.+)|(post-batch-processor.+)/
command("make convert-mml")
else
puts "***" + file
puts "re-generating javascript libraries and css resources for these libraries ..."
command("make src")
end
end
watch(/^imports\/.+/) do |match|
command("make public/imports")
end
watch(/^src\/(.+)(\.sass)|(\.scss)$/) do |match|
path = match[1]
puts path
if path =~ /^sass\//
delete_css
command("make")
else
command("sass -I src -I public src/#{path}.sass public/#{path}.css")
end
end
watch "src/readme.scss" do
command("make")
end
# watch(/(^src\/doc\/.+)/) do |match|
# puts "running make because of change to src/doc file #{match[0]}"
# command("make")
# end
watch(/(^test\/vows\/.+\.js)$/) do |match|
command("./node_modules/.bin/vows --isolate --no-color #{match[0]}")
end
watch(/^test\/vows\/mml-conversions\/(input-mml|expected-json)\/.+/) do
command("./node_modules/.bin/vows --no-color test/vows/mml-conversions/conversion-test.js")
end
watch(/(^test\/mocha\/.+)/) do |match|
command("./node_modules/.bin/mocha #{match[0]}")
end
watch(/(^src\/(?!sass).+)$/) do |match|
unless match[0][/(\.haml)|(\.sass)|(\.scss)|(\.coffee)(\.yaml)|(^\..+)$/]
puts match[0]
source_path = match[0]
destination_path = 'public/' + source_path[/src\/(.+?)$/, 1]
destination_dir = destination_path[/(^.*)\//, 1]
command("mkdir -p #{destination_dir}")
command("cp -f #{source_path} #{destination_path}")
end
end
watch(/^(src\/resources\/[^.].+)$/) do |match|
source_path = match[0]
destination_path = 'public/' + source_path[/src\/(.+?)$/, 1]
command("cp -f #{source_path} #{destination_path}")
end
watch(/^src\/(experiments\/.+)$/) do |match|
source_path = match[0]
destination_path = "public/#{match[1]}"
command("cp -f #{source_path} #{destination_path}")
end
end
# , :api_version => '1.6', :port => '35728'
unless ENV['LAB_USE_LIVE_RELOAD'] == 'NO' then
guard 'livereload' do
watch(/^(public\/).+\.(css|js|html|json)/)
end
end
end
group :test do
guard 'shell' do
watch(/(^src\/lab\/.+)|(^src\/modules\/.+)/) do |match|
file = match[0]
unless file =~ /(lab.config.js)|(lab.version.js)/
command("make test-src")
end
end
watch(/(^src\/helpers\/.+)/) do |match|
file = match[0]
case match[0]
when /\/md2d\/mml-parser/
when /\/md2d\/(mw-batch-converter.+)|(post-batch-processor.+)/
else
command("make test-src")
end
end
end
end