forked from concord-consortium/lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuardfile
executable file
·153 lines (122 loc) · 4.52 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
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 server/public \! -path 'server/public/vendor*' -name '*.css' | xargs rm -f")
end
guard 'sass', :input => 'src/examples', :output => 'server/public/examples', :all_on_start => false, :load_paths => ['src']
guard 'sass', :input => 'src/doc', :output => 'server/public/doc', :all_on_start => false, :load_paths => ['src']
require "./src/helpers/sass/lab_fontface.rb"
guard 'coffeescript', :input => 'src/examples', :output => 'server/public/examples', :all_on_start => false
guard 'coffeescript', :input => 'src/doc', :output => 'server/public/doc', :all_on_start => false
guard 'haml', :input => 'src', :output => 'server/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")
command("make test-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")
command("make test-src")
end
end
watch(/^imports\/.+/) do |match|
command("make server/public/imports")
end
watch(/(^src\/sass\/.+)/) do |match|
puts match[0]
delete_css
command("make")
end
watch "src/index.sass" do
command("bin/sass -I src --require ./src/helpers/sass/lab_fontface.rb src/index.sass server/public/index.css")
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\/examples\/[^.].+)$/) do |match|
unless match[0][/(\.haml)|(\.sass)|(\.scss)|(\.coffee)(\.yaml)|(^\..+)$/]
source_path = match[0]
destination_path = 'server/public/' + source_path[/src\/(.+?)$/, 1]
command("cp -f #{source_path} #{destination_path}")
command("ruby src/helpers/examples/interactives/process-interactives.rb")
end
end
watch(/^(src\/resources\/[^.].+)$/) do |match|
source_path = match[0]
destination_path = 'server/public/' + source_path[/src\/(.+?)$/, 1]
command("cp -f #{source_path} #{destination_path}")
end
watch(/^src\/(experiments\/.+)$/) do |match|
source_path = match[0]
destination_path = "server/public/#{match[1]}"
command("cp -f #{source_path} #{destination_path}")
end
end
# , :api_version => '1.6', :port => '35728'
guard 'livereload' do
watch(/^(server\/public\/).+\.(css|js|html)/)
end
guard 'markdown', :kram_ops => { :toc_levels => [2,3,4,5] } do
watch "readme.md" do |m|
"readme.md|server/public/readme.html|src/layouts/readme.html.erb"
end
watch "license.md" do |m|
"license.md|server/public/license.html|src/layouts/license.html.erb"
end
end