forked from idflood/ThreeNodes.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
compile
executable file
·50 lines (37 loc) · 757 Bytes
/
compile
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
#!/usr/bin/ruby
require 'find'
@haml_cmd = 'haml'
@compass_cmd = 'compass compile'
@coffee_cmd = 'cake build'
files = {}
def exec(cmd)
puts "# Run: #{cmd}"
output = `#{cmd}`
print output
end
def compile_file(f, file_out)
cmd = nil
case f
when /\.coffee$/ : cmd = @coffee_cmd
when /\.haml$/
cmd = @haml_cmd
file_out["src/haml/"] = "public/"
file_out[".haml"] = ".html"
cmd += " " + f + " " + file_out
when /\.scss$/, /\.sass$/ : cmd = @compass_cmd
end
if cmd != nil
exec cmd
end
end
loop do
Find.find('src/') do |f|
ctime = File.ctime(f).to_i
if ctime != files[f]
files[f] = ctime
f_out = f.clone
compile_file f, f_out
end
end
sleep 1
end