From 8b02a65ab43521234e4847c8351e3ca8cd03681b Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Fri, 16 Oct 2009 17:35:43 -0700 Subject: [PATCH] Fix bugs in the dry-run mode of project creation. --- lib/compass/actions.rb | 2 +- lib/compass/commands/update_project.rb | 10 +++++++--- lib/compass/exec/sub_command_ui.rb | 6 +++--- lib/compass/installers/base.rb | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/compass/actions.rb b/lib/compass/actions.rb index 0c7c2cae..2d2875d0 100644 --- a/lib/compass/actions.rb +++ b/lib/compass/actions.rb @@ -48,7 +48,7 @@ module Compass logger.record :create, basename(file_name) end if skip_write - FileUtils.touch file_name + FileUtils.touch file_name unless options[:dry_run] else mode = "w" mode << "b" if binary diff --git a/lib/compass/commands/update_project.rb b/lib/compass/commands/update_project.rb index 709dd2aa..f1f89a01 100644 --- a/lib/compass/commands/update_project.rb +++ b/lib/compass/commands/update_project.rb @@ -7,12 +7,12 @@ module Compass def initialize(working_path, options) super - assert_project_directory_exists! + assert_project_directory_exists! unless dry_run? end def perform 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 << "Run \"compass -h\" to get help." raise Compass::Error, message @@ -21,6 +21,10 @@ module Compass end end + def dry_run? + options[:dry_run] + end + def new_compiler_instance(additional_options = {}) Compass::Compiler.new(working_path, projectize(Compass.configuration.sass_dir), @@ -31,4 +35,4 @@ module Compass end end -end \ No newline at end of file +end diff --git a/lib/compass/exec/sub_command_ui.rb b/lib/compass/exec/sub_command_ui.rb index e7b33260..45ff9c84 100644 --- a/lib/compass/exec/sub_command_ui.rb +++ b/lib/compass/exec/sub_command_ui.rb @@ -18,7 +18,7 @@ module Compass::Exec if e.is_a?(::Compass::Error) || e.is_a?(OptionParser::ParseError) $stderr.puts e.message else - ::Compass::Exec::Helpers.report_error(e, @options) + ::Compass::Exec::Helpers.report_error(e, @options || {}) end return 1 end @@ -30,12 +30,12 @@ module Compass::Exec def perform! $command = args.shift 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) else command_class.parse!(args) end - command_class.new(Dir.getwd, options).execute + command_class.new(Dir.getwd, @options).execute rescue OptionParser::ParseError => e puts "Error: #{e.message}" puts command_class.usage diff --git a/lib/compass/installers/base.rb b/lib/compass/installers/base.rb index c47d609c..2261fdd5 100644 --- a/lib/compass/installers/base.rb +++ b/lib/compass/installers/base.rb @@ -54,7 +54,7 @@ module Compass def run(options = {}) prepare install - finalize unless options[:skip_finalization] + finalize(options) unless options[:skip_finalization] end # The default prepare method -- it is a no-op.