Fix bugs in the dry-run mode of project creation.

This commit is contained in:
Chris Eppstein 2009-10-16 17:35:43 -07:00
parent f6b138062f
commit 8b02a65ab4
4 changed files with 12 additions and 8 deletions

View File

@ -48,7 +48,7 @@ module Compass
logger.record :create, basename(file_name) logger.record :create, basename(file_name)
end end
if skip_write if skip_write
FileUtils.touch file_name FileUtils.touch file_name unless options[:dry_run]
else else
mode = "w" mode = "w"
mode << "b" if binary mode << "b" if binary

View File

@ -7,12 +7,12 @@ module Compass
def initialize(working_path, options) def initialize(working_path, options)
super super
assert_project_directory_exists! assert_project_directory_exists! unless dry_run?
end end
def perform def perform
compiler = new_compiler_instance compiler = new_compiler_instance
if compiler.sass_files.empty? if compiler.sass_files.empty? && !dry_run?
message = "Nothing to compile. If you're trying to start a new project, you have left off the directory argument.\n" message = "Nothing to compile. If you're trying to start a new project, you have left off the directory argument.\n"
message << "Run \"compass -h\" to get help." message << "Run \"compass -h\" to get help."
raise Compass::Error, message raise Compass::Error, message
@ -21,6 +21,10 @@ module Compass
end end
end end
def dry_run?
options[:dry_run]
end
def new_compiler_instance(additional_options = {}) def new_compiler_instance(additional_options = {})
Compass::Compiler.new(working_path, Compass::Compiler.new(working_path,
projectize(Compass.configuration.sass_dir), projectize(Compass.configuration.sass_dir),

View File

@ -18,7 +18,7 @@ module Compass::Exec
if e.is_a?(::Compass::Error) || e.is_a?(OptionParser::ParseError) if e.is_a?(::Compass::Error) || e.is_a?(OptionParser::ParseError)
$stderr.puts e.message $stderr.puts e.message
else else
::Compass::Exec::Helpers.report_error(e, @options) ::Compass::Exec::Helpers.report_error(e, @options || {})
end end
return 1 return 1
end end
@ -30,12 +30,12 @@ module Compass::Exec
def perform! def perform!
$command = args.shift $command = args.shift
command_class = Compass::Commands[$command] command_class = Compass::Commands[$command]
options = if command_class.respond_to?("parse_#{$command}!") @options = if command_class.respond_to?("parse_#{$command}!")
command_class.send("parse_#{$command}!", args) command_class.send("parse_#{$command}!", args)
else else
command_class.parse!(args) command_class.parse!(args)
end end
command_class.new(Dir.getwd, options).execute command_class.new(Dir.getwd, @options).execute
rescue OptionParser::ParseError => e rescue OptionParser::ParseError => e
puts "Error: #{e.message}" puts "Error: #{e.message}"
puts command_class.usage puts command_class.usage

View File

@ -54,7 +54,7 @@ module Compass
def run(options = {}) def run(options = {})
prepare prepare
install install
finalize unless options[:skip_finalization] finalize(options) unless options[:skip_finalization]
end end
# The default prepare method -- it is a no-op. # The default prepare method -- it is a no-op.