Merge pull request #1115 from imathis/colorize

Colorize Terminal Errors/Warnings
This commit is contained in:
Parker Moore 2013-04-02 11:53:31 -07:00
commit f430bd82da
4 changed files with 19 additions and 13 deletions

View File

@ -1,3 +1,5 @@
require File.expand_path('../../lib/colors.rb', __FILE__)
module Jekyll
require 'haml'
class HamlConverter < Converter
@ -17,7 +19,7 @@ module Jekyll
engine = Haml::Engine.new(content)
engine.render
rescue StandardError => e
puts "!!! HAML Error: " + e.message
$stderr.puts ("!!! HAML Error: " + e.message).red
end
end
end

View File

@ -20,6 +20,7 @@
# will output a figcaption with the title: Example 2 (test.js)
#
require File.expand_path('../../lib/colors.rb', __FILE__)
require './plugins/pygments_code'
require 'pathname'
@ -62,21 +63,21 @@ module Jekyll
unless @title_old.nil?
@options[:title] ||= @title_old
puts "### ------------ WARNING ------------ ###"
puts "This include_code syntax is deprecated "
puts "Correct syntax: path/to/file.ext [title]"
puts "Update include for #{filepath}"
puts "### --------------------------------- ###"
puts "### ------------ WARNING ------------ ###".yellow
puts "This include_code syntax is deprecated ".yellow
puts "Correct syntax: path/to/file.ext [title]".yellow
puts "Update include for #{filepath}".yellow
puts "### --------------------------------- ###".yellow
end
if File.symlink?(code_path)
puts "Code directory '#{code_path}' cannot be a symlink"
return "Code directory '#{code_path}' cannot be a symlink"
puts "Code directory '#{code_path}' cannot be a symlink".yellow
return "Code directory '#{code_path}' cannot be a symlink".yellow
end
unless filepath.file?
puts "File #{filepath} could not be found"
return "File #{filepath} could not be found"
puts "File #{filepath} could not be found".yellow
return "File #{filepath} could not be found".yellow
end
Dir.chdir(code_path) do

View File

@ -1,3 +1,5 @@
require File.expand_path('../../lib/colors.rb', __FILE__)
module Jekyll
module Generators
class Pagination < Generator
@ -89,7 +91,7 @@ module Jekyll
@total_pages = num_pages || Pager.calculate_pages(all_posts, @per_page)
if @page > @total_pages
raise RuntimeError, "page number can't be greater than total pages: #{@page} > #{@total_pages}"
raise RuntimeError, "page number can't be greater than total pages: #{@page} > #{@total_pages}".red
end
init = (@page - 1) * @per_page

View File

@ -36,6 +36,7 @@
#
# Modified for Octopress by John W. Long
#
require File.expand_path('../../lib/colors.rb', __FILE__)
require 'rexml/document'
require 'fileutils'
@ -193,7 +194,7 @@ module Jekyll
changefreq.text = change_frequency
url.add_element(changefreq)
else
puts "ERROR: Invalid Change Frequency In #{page_or_post.name}"
$stderr.puts "ERROR: Invalid Change Frequency In #{page_or_post.name}".red
end
end
@ -204,7 +205,7 @@ module Jekyll
priority.text = page_or_post.data[PRIORITY_CUSTOM_VARIABLE_NAME]
url.add_element(priority)
else
puts "ERROR: Invalid Priority In #{page_or_post.name}"
$stderr.puts "ERROR: Invalid Priority In #{page_or_post.name}".red
end
end