Skip to content

Instantly share code, notes, and snippets.

@jlong
Created July 21, 2009 15:35
Show Gist options
  • Save jlong/151399 to your computer and use it in GitHub Desktop.
Save jlong/151399 to your computer and use it in GitHub Desktop.
rakefile for jekyll
require 'active_support'
def ok_failed(condition)
if (condition)
puts "OK"
else
puts "FAILED"
end
end
port = "2345"
desc "list tasks"
task :default do
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:default]]).to_sentence}"
puts "(type rake -T for more detail)\n\n"
end
desc "remove files in output directory"
task :clean do
puts "Removing output..."
Dir["output/*"].each { |f| rm_rf(f) }
end
desc "generate website in output directory"
task :generate => :clean do
puts "Generating website..."
system "jekyll"
end
desc "generate and deploy website"
task :deploy => :generate do
print "Deploying website..."
system("rsync -avz --delete --rsync-path=/usr/local/bin/rsync output/ [email protected]:~/domains/recursivecreative.com/web/public")
end
desc "start up an instance of serve on the output files"
task :start_serve => :stop_serve do
cd "output" do
print "Starting serve..."
ok_failed system("serve #{port} > /dev/null 2>&1 &")
end
end
desc "stop all instances of serve"
task :stop_serve do
pid = `ps auxw | awk '/usr\\/bin\\/serve\\ #{port}/ { print $2 }'`.strip
if pid.empty?
puts "Serve is not running"
else
print "Stoping serve..."
ok_failed system("kill -9 #{pid}")
end
end
desc "preview the site in a web browser"
multitask :preview => [:generate, :start_serve] do
system "open http://localhost:2345"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment