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 += ['*']
 | 
					        dirs += ['*']
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    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
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,15 +20,7 @@ module Jekyll
 | 
				
			||||||
        puts  "            Source: #{source}"
 | 
					        puts  "            Source: #{source}"
 | 
				
			||||||
        puts  "       Destination: #{destination}"
 | 
					        puts  "       Destination: #{destination}"
 | 
				
			||||||
        print "      Generating... "
 | 
					        print "      Generating... "
 | 
				
			||||||
        begin
 | 
					        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
 | 
					 | 
				
			||||||
        puts "done."
 | 
					        puts "done."
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,15 +44,7 @@ module Jekyll
 | 
				
			||||||
        dw.add_observer do |*args|
 | 
					        dw.add_observer do |*args|
 | 
				
			||||||
          t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
 | 
					          t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
 | 
				
			||||||
          print "      Regenerating: #{args.size} files at #{t} "
 | 
					          print "      Regenerating: #{args.size} files at #{t} "
 | 
				
			||||||
          begin
 | 
					          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
 | 
					 | 
				
			||||||
          puts  "...done."
 | 
					          puts  "...done."
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue