Merge pull request #952 from mojombo/refactor-commands
Remove code duplication in Build command
This commit is contained in:
		
						commit
						25a882fa75
					
				|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue