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,
|
||||
:load_paths => options[:load_paths],
|
||||
: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))
|
||||
else
|
||||
logger.record :unchanged, basename(sass_filename) unless options[:quiet]
|
||||
|
@ -1,8 +1,11 @@
|
||||
module Compass
|
||||
|
||||
class Logger
|
||||
|
||||
DEFAULT_ACTIONS = [:directory, :exists, :remove, :create, :overwrite, :compile, :error, :identical]
|
||||
|
||||
COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33 }
|
||||
|
||||
ACTION_COLORS = {
|
||||
:error => :red,
|
||||
:compile => :green,
|
||||
@ -14,7 +17,6 @@ module Compass
|
||||
:identical => :green
|
||||
}
|
||||
|
||||
COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33 }
|
||||
|
||||
attr_accessor :actions, :options
|
||||
|
||||
@ -26,9 +28,21 @@ module Compass
|
||||
|
||||
# Record an action that has occurred
|
||||
def record(action, *arguments)
|
||||
emit color(ACTION_COLORS[action]) if Compass.configuration.color_output
|
||||
log "#{action_padding(action)}#{action} #{arguments.join(' ')}"
|
||||
emit color(:clear) if Compass.configuration.color_output
|
||||
msg = ""
|
||||
msg << color(ACTION_COLORS[action]) 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
|
||||
|
||||
def color(c)
|
||||
@ -42,6 +56,7 @@ module Compass
|
||||
def emit(msg)
|
||||
print msg
|
||||
end
|
||||
|
||||
# Emit a log message
|
||||
def log(msg)
|
||||
puts msg
|
||||
@ -64,5 +79,9 @@ module Compass
|
||||
|
||||
def log(msg)
|
||||
end
|
||||
|
||||
def red
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user