... | ... |
@@ -50,12 +50,42 @@ end |
50 | 50 |
|
51 | 51 |
desc "Watch the site and regenerate when it changes" |
52 | 52 |
task :watch do |
53 |
- system "trap 'kill $jekyllPid $compassPid' Exit; jekyll --auto & jekyllPid=$!; compass watch & compassPid=$!; wait" |
|
53 |
+require 'compass' |
|
54 |
+require 'compass/exec' |
|
55 |
+ puts "Starting to watch source with Jekyll and Compass." |
|
56 |
+ jekyllPid = spawn("jekyll --auto") |
|
57 |
+ compassPid = spawn("compass watch") |
|
58 |
+ |
|
59 |
+ trap("INT") { |
|
60 |
+ Process.kill(9, jekyllPid) |
|
61 |
+ Process.kill(9, compassPid) |
|
62 |
+ puts "Waiting for Jekyll and Compass to die." |
|
63 |
+ sleep 5 |
|
64 |
+ puts "Done waiting. Bye bye." |
|
65 |
+ exit 0 |
|
66 |
+ } |
|
67 |
+ |
|
68 |
+ Process.wait |
|
54 | 69 |
end |
55 | 70 |
|
56 | 71 |
desc "preview the site in a web browser" |
57 | 72 |
task :preview do |
58 |
- system "trap 'kill $jekyllPid $compassPid $rackPid' Exit; jekyll --auto & jekyllPid=$!; compass watch & compassPid=$!; rackup --port #{server_port} & rackPid=$!; wait" |
|
73 |
+ puts "Starting to watch source with Jekyll and Compass. Starting Rack on port #{server_port}" |
|
74 |
+ jekyllPid = spawn("jekyll --auto") |
|
75 |
+ compassPid = spawn("compass watch") |
|
76 |
+ rackupPid = spawn("rackup --port #{server_port}") |
|
77 |
+ |
|
78 |
+ trap("INT") { |
|
79 |
+ Process.kill(9, jekyllPid) |
|
80 |
+ Process.kill(9, compassPid) |
|
81 |
+ Process.kill(9, rackupPid) |
|
82 |
+ puts "Waiting for Jekyll, Compass and Rack to die." |
|
83 |
+ sleep 10 |
|
84 |
+ puts "Done waiting. Bye bye." |
|
85 |
+ exit 0 |
|
86 |
+ } |
|
87 |
+ |
|
88 |
+ Process.wait |
|
59 | 89 |
end |
60 | 90 |
|
61 | 91 |
# usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post") |