Do not rely on system specifc syntax for preview or watch.

This commit is contained in:
Benjamin R Doerr 2011-08-23 22:55:16 -04:00
parent 5f08abe6dd
commit efb7522491

View File

@ -50,12 +50,42 @@ end
desc "Watch the site and regenerate when it changes"
task :watch do
system "trap 'kill $jekyllPid $compassPid' Exit; jekyll --auto & jekyllPid=$!; compass watch & compassPid=$!; wait"
require 'compass'
require 'compass/exec'
puts "Starting to watch source with Jekyll and Compass."
jekyllPid = spawn("jekyll --auto")
compassPid = spawn("compass watch")
trap("INT") {
Process.kill(9, jekyllPid)
Process.kill(9, compassPid)
puts "Waiting for Jekyll and Compass to die."
sleep 5
puts "Done waiting. Bye bye."
exit 0
}
Process.wait
end
desc "preview the site in a web browser"
task :preview do
system "trap 'kill $jekyllPid $compassPid $rackPid' Exit; jekyll --auto & jekyllPid=$!; compass watch & compassPid=$!; rackup --port #{server_port} & rackPid=$!; wait"
puts "Starting to watch source with Jekyll and Compass. Starting Rack on port #{server_port}"
jekyllPid = spawn("jekyll --auto")
compassPid = spawn("compass watch")
rackupPid = spawn("rackup --port #{server_port}")
trap("INT") {
Process.kill(9, jekyllPid)
Process.kill(9, compassPid)
Process.kill(9, rackupPid)
puts "Waiting for Jekyll, Compass and Rack to die."
sleep 10
puts "Done waiting. Bye bye."
exit 0
}
Process.wait
end
# usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post")