def write_file(file_name, contents, options = nil, binary = false)
options ||= self.options if self.respond_to?(:options)
skip_write = options[:dry_run]
contents = process_erb(contents, options[:erb]) if options[:erb]
if File.exists?(file_name)
existing_contents = IO.read(file_name)
if existing_contents == contents
log_action :identical, basename(file_name), options
skip_write = true
elsif options[:force]
log_action :overwrite, basename(file_name), options
else
msg = "File #{basename(file_name)} already exists. Run with --force to force overwrite."
raise Compass::FilesystemConflict.new(msg)
end
else
log_action :create, basename(file_name), options
end
if skip_write
FileUtils.touch file_name unless options[:dry_run]
else
Sass::Util.atomic_create_and_write_file(file_name) do |file|
file.write(contents)
end
end
end