Following a similar API to how the Complier works, don't log
anything (don't even load up the logger!) if we pass in the :quiet option. I need this because of some conflicts with Compass::Logger, being referred to as "Logger", which seemed to be pulling out the main Logger. This is a seperate issue, but making this options[:quiet] API functional is a nice work-around that keeps things from getting too messy. Tests included, obviously.
This commit is contained in:
parent
9add993129
commit
3bf3ddac72
@ -24,7 +24,7 @@ module Compass
|
||||
msg = "#{basename(dir)} already exists and is not a directory."
|
||||
raise Compass::FilesystemConflict.new(msg)
|
||||
else
|
||||
logger.record :directory, separate("#{basename(dir)}/")
|
||||
logger.record(:directory, separate("#{basename(dir)}/")) unless options[:quiet]
|
||||
FileUtils.mkdir_p(dir) unless options[:dry_run]
|
||||
end
|
||||
end
|
||||
@ -38,16 +38,16 @@ module Compass
|
||||
if File.exists?(file_name)
|
||||
existing_contents = IO.read(file_name)
|
||||
if existing_contents == contents
|
||||
logger.record :identical, basename(file_name), extra
|
||||
logger.record(:identical, basename(file_name), extra) unless options[:quiet]
|
||||
skip_write = true
|
||||
elsif options[:force]
|
||||
logger.record :overwrite, basename(file_name), extra
|
||||
logger.record(:overwrite, basename(file_name), extra) unless options[:quiet]
|
||||
else
|
||||
msg = "File #{basename(file_name)} already exists. Run with --force to force overwrite."
|
||||
raise Compass::FilesystemConflict.new(msg)
|
||||
end
|
||||
else
|
||||
logger.record :create, basename(file_name), extra
|
||||
logger.record(:create, basename(file_name), extra) unless options[:quiet]
|
||||
end
|
||||
if skip_write
|
||||
FileUtils.touch file_name unless options[:dry_run]
|
||||
@ -68,7 +68,7 @@ module Compass
|
||||
def remove(file_name)
|
||||
if File.exists?(file_name)
|
||||
File.unlink file_name
|
||||
logger.record :remove, basename(file_name)
|
||||
logger.record(:remove, basename(file_name)) unless options[:quiet]
|
||||
end
|
||||
end
|
||||
|
||||
|
24
test/units/actions_test.rb
Normal file
24
test/units/actions_test.rb
Normal file
@ -0,0 +1,24 @@
|
||||
require 'test_helper'
|
||||
require 'compass'
|
||||
|
||||
class ActionsTest < Test::Unit::TestCase
|
||||
class BaseActionExtender
|
||||
include Compass::Actions
|
||||
def options
|
||||
@@options ||= {}
|
||||
end
|
||||
def working_path
|
||||
"/tmp"
|
||||
end
|
||||
end
|
||||
|
||||
# When log4r is included, it sometimes breaks the Actions
|
||||
def test_quiet_option
|
||||
b = BaseActionExtender.new
|
||||
b.logger = ""
|
||||
b.options[:quiet] = true
|
||||
|
||||
# logger shouldn't be called... if it is, this will error
|
||||
b.directory("/tmp/#{(rand * 1000000).to_i}")
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user