Instead of a sleep hack, just use a Jekyll hook! 😄

This commit is contained in:
Parker Moore 2016-11-02 14:11:40 -07:00
parent b108f4c87e
commit 8b2a35dc50
No known key found for this signature in database
GPG Key ID: 193CDEBA72063C58
1 changed files with 8 additions and 14 deletions

View File

@ -12,11 +12,11 @@ namespace :site do
require "launchy"
require "jekyll"
# Yep, it's a hack! Wait a few seconds for the Jekyll site to generate and
# then open it in a browser. Someday we can do better than this, I hope.
Thread.new do
sleep 4
puts "Opening in browser..."
browser_launched = false
Jekyll::Hooks.register :site, :post_write do |site|
next if browser_launched
browser_launched = true
Jekyll.logger.info "Opening in browser..."
Launchy.open("http://localhost:4000")
end
@ -54,14 +54,8 @@ namespace :site do
desc "Generate generated pages and publish to GitHub Pages"
task :publish => :generated_pages do
puts "Committing and pushing to GitHub Pages..."
sha = `git rev-parse HEAD`.strip
Dir.chdir('gh-pages') do
sh "git add docs/"
sh "git commit --allow-empty -m 'Generating pages for #{sha}.'"
sh "git push origin master"
end
puts 'Done.'
puts "GitHub Pages now compiles our docs site on every push to the `master` branch. Cool, huh?"
exit 1
end
desc "Create a nicely formatted history page for the jekyll site based on the repo history."