[Command Line] Specification of sass files to compile
The command line compiler now lets you target specific sass files for compilation. When specified explicitly, the sass files are always compiled even if they are older than the corresponding css file (--force is implied). Usage Examples: From the project directory: compass compile src/screen.sass src/ie.sass From another directory: compass compile my_project my_project/src/screen.sass my_project/src/ie.sass
This commit is contained in:
parent
a3cdf182c9
commit
6d6e1ca0e3
@ -120,6 +120,26 @@ Feature: Command Line
|
||||
And a sass file sass/reset.sass is reported unchanged
|
||||
And a sass file sass/utilities.sass is reported unchanged
|
||||
|
||||
Scenario: compiling a specific file in a project
|
||||
Given I am using the existing project in test/fixtures/stylesheets/compass
|
||||
And I run: compass compile sass/utilities.sass
|
||||
Then a sass file sass/layout.sass is not mentioned
|
||||
And a sass file sass/print.sass is not mentioned
|
||||
And a sass file sass/reset.sass is not mentioned
|
||||
And a sass file sass/utilities.sass is reported compiled
|
||||
And a css file tmp/utilities.css is reported created
|
||||
And a css file tmp/utilities.css is created
|
||||
|
||||
Scenario: Re-compiling a specific file in a project with no changes
|
||||
Given I am using the existing project in test/fixtures/stylesheets/compass
|
||||
When I run: compass compile
|
||||
And I run: compass compile sass/utilities.sass
|
||||
Then a sass file sass/layout.sass is not mentioned
|
||||
And a sass file sass/print.sass is not mentioned
|
||||
And a sass file sass/reset.sass is not mentioned
|
||||
And a sass file sass/utilities.sass is reported compiled
|
||||
And a css file tmp/utilities.css is reported identical
|
||||
|
||||
Scenario: Installing a pattern into a project
|
||||
Given I am using the existing project in test/fixtures/stylesheets/compass
|
||||
When I run: compass install blueprint/buttons
|
||||
@ -129,7 +149,6 @@ Feature: Command Line
|
||||
And an image file images/buttons/tick.png is created
|
||||
And a css file tmp/buttons.css is created
|
||||
|
||||
@now
|
||||
Scenario: Basic help
|
||||
When I run: compass help
|
||||
Then I should see the following "primary" commands:
|
||||
|
@ -135,6 +135,10 @@ Then /a \w+ file ([^ ]+) is reported overwritten/ do |filename|
|
||||
@last_result.should =~ /overwrite #{Regexp.escape(filename)}/
|
||||
end
|
||||
|
||||
Then /a \w+ file ([^ ]+) is not mentioned/ do |filename|
|
||||
@last_result.should_not =~ /#{Regexp.escape(filename)}/
|
||||
end
|
||||
|
||||
Then /I am told how to link to ([^ ]+) for media "([^"]+)"/ do |stylesheet, media|
|
||||
@last_result.should =~ %r{<link href="#{stylesheet}" media="#{media}" rel="stylesheet" type="text/css" />}
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ module Compass
|
||||
module CompileProjectOptionsParser
|
||||
def set_options(opts)
|
||||
opts.banner = %Q{
|
||||
Usage: compass compile [path/to/project] [options]
|
||||
Usage: compass compile [path/to/project] [path/to/project/src/file.sass ...] [options]
|
||||
|
||||
Description:
|
||||
compile project at the path specified or the current director if not specified.
|
||||
@ -47,9 +47,22 @@ module Compass
|
||||
projectize(Compass.configuration.sass_dir),
|
||||
projectize(Compass.configuration.css_dir),
|
||||
Compass.sass_engine_options.merge(:quiet => options[:quiet],
|
||||
:force => options[:force]).merge(additional_options))
|
||||
:force => options[:force],
|
||||
:sass_files => explicit_sass_files).merge(additional_options))
|
||||
end
|
||||
|
||||
def explicit_sass_files
|
||||
return unless options[:sass_files]
|
||||
options[:sass_files].map do |sass_file|
|
||||
if absolute_path? sass_file
|
||||
sass_file
|
||||
else
|
||||
File.join(Dir.pwd, sass_file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class << self
|
||||
def option_parser(arguments)
|
||||
parser = Compass::Exec::CommandOptionParser.new(arguments)
|
||||
@ -76,10 +89,12 @@ module Compass
|
||||
end
|
||||
|
||||
def parse_arguments!(parser, arguments)
|
||||
if arguments.size == 1
|
||||
parser.options[:project_name] = arguments.shift
|
||||
elsif arguments.size > 1
|
||||
raise Compass::Error, "Too many arguments were specified."
|
||||
if arguments.size > 0
|
||||
parser.options[:project_name] = arguments.shift if File.directory?(arguments.first)
|
||||
unless arguments.empty?
|
||||
parser.options[:sass_files] = arguments.dup
|
||||
parser.options[:force] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -15,7 +15,7 @@ module Compass
|
||||
|
||||
def sass_files(options = {})
|
||||
exclude_partials = options.fetch(:exclude_partials, true)
|
||||
@sass_files || Dir.glob(separate("#{from}/**/#{'[^_]' if exclude_partials}*.sass"))
|
||||
@sass_files = self.options[:sass_files] || Dir.glob(separate("#{from}/**/#{'[^_]' if exclude_partials}*.sass"))
|
||||
end
|
||||
|
||||
def stylesheet_name(sass_file)
|
||||
|
Loading…
Reference in New Issue
Block a user