Merge pull request #952 from mojombo/refactor-commands

Remove code duplication in Build command
This commit is contained in:
Parker Moore 2013-04-12 13:36:19 -07:00
commit 25a882fa75
2 changed files with 17 additions and 18 deletions

View File

@ -8,5 +8,20 @@ module Jekyll
dirs += ['*']
end
end
# Static: Run Site#process and catch errors
#
# site - the Jekyll::Site object
#
# Returns nothing
def self.process_site(site)
site.process
rescue Jekyll::FatalException => e
puts
puts "ERROR: YOUR SITE COULD NOT BE BUILT:"
puts "------------------------------------"
puts e.message
exit(1)
end
end
end

View File

@ -20,15 +20,7 @@ module Jekyll
puts " Source: #{source}"
puts " Destination: #{destination}"
print " Generating... "
begin
site.process
rescue Jekyll::FatalException => e
puts
puts "ERROR: YOUR SITE COULD NOT BE BUILT:"
puts "------------------------------------"
puts e.message
exit(1)
end
self.process_site(site)
puts "done."
end
@ -52,15 +44,7 @@ module Jekyll
dw.add_observer do |*args|
t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
print " Regenerating: #{args.size} files at #{t} "
begin
site.process
rescue Jekyll::FatalException => e
puts
puts "ERROR: YOUR SITE COULD NOT BE BUILT:"
puts "------------------------------------"
puts e.message
exit(1)
end
self.process_site(site)
puts "...done."
end