Return a non-zero exit code if there are any stylesheet compilation errors. Closes GH-432.
This commit is contained in:
parent
23d3d341de
commit
b8b6af9d49
@ -63,6 +63,15 @@ Feature: Command Line
|
||||
And I am told that I can place stylesheets in the sass subdirectory
|
||||
And I am told how to compile my sass stylesheets
|
||||
|
||||
Scenario: Compiling a project with errors
|
||||
Given I am using the existing project in test/fixtures/stylesheets/compass
|
||||
And the project has a file named "sass/error.scss" containing:
|
||||
"""
|
||||
.broken {
|
||||
"""
|
||||
When I run: compass compile
|
||||
Then the command exits with a non-zero error code
|
||||
|
||||
Scenario: Creating a bare project with a framework
|
||||
When I create a project using: compass create bare_project --using blueprint --bare
|
||||
Then an error message is printed out: A bare project cannot be created when a framework is specified.
|
||||
|
@ -53,6 +53,13 @@ Given /^I should clean up the directory: (\w+)$/ do |directory|
|
||||
@cleanup_directories << directory
|
||||
end
|
||||
|
||||
Given %r{^the project has a file named "([^"]*)" containing:$} do |arg1, string|
|
||||
File.open(arg1, "w") do |f|
|
||||
f << string
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# When Actions are performed
|
||||
When /^I create a project using: compass create ([^\s]+) ?(.+)?$/ do |dir, args|
|
||||
@cleanup_directories << dir
|
||||
|
@ -22,6 +22,14 @@ module Compass
|
||||
raise StandardError.new("Not Implemented")
|
||||
end
|
||||
|
||||
def successful?
|
||||
!@failed
|
||||
end
|
||||
|
||||
def failed!
|
||||
@failed = true
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def framework
|
||||
|
@ -34,7 +34,8 @@ module Compass
|
||||
compiler = new_compiler_instance
|
||||
check_for_sass_files!(compiler)
|
||||
compiler.clean! if compiler.new_config?
|
||||
compiler.run
|
||||
error_count = compiler.run
|
||||
failed! if error_count > 0
|
||||
end
|
||||
|
||||
def check_for_sass_files!(compiler)
|
||||
|
@ -82,6 +82,7 @@ module Compass
|
||||
end
|
||||
|
||||
def run
|
||||
failure_count = 0
|
||||
if new_config?
|
||||
# Wipe out the cache and force compilation if the configuration has changed.
|
||||
remove options[:cache_location] if options[:cache_location]
|
||||
@ -97,6 +98,7 @@ module Compass
|
||||
begin
|
||||
compile_if_required sass_filename, css_filename
|
||||
rescue Sass::SyntaxError => e
|
||||
failure_count += 1
|
||||
handle_exception(sass_filename, css_filename, e)
|
||||
end
|
||||
end
|
||||
@ -104,6 +106,7 @@ module Compass
|
||||
if options[:time]
|
||||
puts "Compilation took #{(result.__duration * 1000).round / 1000.0}s"
|
||||
end
|
||||
return failure_count
|
||||
end
|
||||
|
||||
def compile_if_required(sass_filename, css_filename)
|
||||
|
@ -12,8 +12,7 @@ module Compass::Exec
|
||||
|
||||
def run!
|
||||
begin
|
||||
perform!
|
||||
return 0
|
||||
return perform!
|
||||
rescue Exception => e
|
||||
raise e if e.is_a? SystemExit
|
||||
if e.is_a?(::Compass::Error) || e.is_a?(OptionParser::ParseError)
|
||||
@ -40,7 +39,9 @@ module Compass::Exec
|
||||
else
|
||||
command_class.parse!(args)
|
||||
end
|
||||
command_class.new(Dir.getwd, @options).execute
|
||||
cmd = command_class.new(Dir.getwd, @options)
|
||||
cmd.execute
|
||||
cmd.successful? ? 0 : 1
|
||||
rescue OptionParser::ParseError => e
|
||||
puts "Error: #{e.message}"
|
||||
puts command_class.usage if command_class.respond_to?(:usage)
|
||||
|
Loading…
Reference in New Issue
Block a user