Color any stderr or stdout output from the Sass::Engine red.
This commit is contained in:
parent
a5835d24a7
commit
c60aca3d96
@ -74,7 +74,9 @@ module Compass
|
|||||||
:css_filename => css_filename,
|
:css_filename => css_filename,
|
||||||
:load_paths => options[:load_paths],
|
:load_paths => options[:load_paths],
|
||||||
:cache_location => options[:cache_location])
|
:cache_location => options[:cache_location])
|
||||||
css_content = engine.render
|
css_content = logger.red do
|
||||||
|
engine.render
|
||||||
|
end
|
||||||
write_file(css_filename, css_content, options.merge(:force => true))
|
write_file(css_filename, css_content, options.merge(:force => true))
|
||||||
else
|
else
|
||||||
logger.record :unchanged, basename(sass_filename) unless options[:quiet]
|
logger.record :unchanged, basename(sass_filename) unless options[:quiet]
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
module Compass
|
module Compass
|
||||||
|
|
||||||
class Logger
|
class Logger
|
||||||
|
|
||||||
DEFAULT_ACTIONS = [:directory, :exists, :remove, :create, :overwrite, :compile, :error, :identical]
|
DEFAULT_ACTIONS = [:directory, :exists, :remove, :create, :overwrite, :compile, :error, :identical]
|
||||||
|
|
||||||
|
COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33 }
|
||||||
|
|
||||||
ACTION_COLORS = {
|
ACTION_COLORS = {
|
||||||
:error => :red,
|
:error => :red,
|
||||||
:compile => :green,
|
:compile => :green,
|
||||||
@ -14,7 +17,6 @@ module Compass
|
|||||||
:identical => :green
|
:identical => :green
|
||||||
}
|
}
|
||||||
|
|
||||||
COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33 }
|
|
||||||
|
|
||||||
attr_accessor :actions, :options
|
attr_accessor :actions, :options
|
||||||
|
|
||||||
@ -26,9 +28,21 @@ module Compass
|
|||||||
|
|
||||||
# Record an action that has occurred
|
# Record an action that has occurred
|
||||||
def record(action, *arguments)
|
def record(action, *arguments)
|
||||||
emit color(ACTION_COLORS[action]) if Compass.configuration.color_output
|
msg = ""
|
||||||
log "#{action_padding(action)}#{action} #{arguments.join(' ')}"
|
msg << color(ACTION_COLORS[action]) if Compass.configuration.color_output
|
||||||
emit color(:clear) if Compass.configuration.color_output
|
msg << "#{action_padding(action)}#{action} #{arguments.join(' ')}"
|
||||||
|
msg << color(:clear) if Compass.configuration.color_output
|
||||||
|
log msg
|
||||||
|
end
|
||||||
|
|
||||||
|
def red
|
||||||
|
return yield unless Compass.configuration.color_output
|
||||||
|
$stderr.write(color(:red))
|
||||||
|
$stdout.write(color(:red))
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
$stderr.write(color(:clear))
|
||||||
|
$stdout.write(color(:clear))
|
||||||
end
|
end
|
||||||
|
|
||||||
def color(c)
|
def color(c)
|
||||||
@ -42,6 +56,7 @@ module Compass
|
|||||||
def emit(msg)
|
def emit(msg)
|
||||||
print msg
|
print msg
|
||||||
end
|
end
|
||||||
|
|
||||||
# Emit a log message
|
# Emit a log message
|
||||||
def log(msg)
|
def log(msg)
|
||||||
puts msg
|
puts msg
|
||||||
@ -64,5 +79,9 @@ module Compass
|
|||||||
|
|
||||||
def log(msg)
|
def log(msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def red
|
||||||
|
yield
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user