Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom environments #1322

Open
wants to merge 5 commits into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -102,7 +102,9 @@ later on.
<td style="vertical-align:top;"><code>environment</code> </td>
<td style="vertical-align:top;">Symbol </td>
<td style="vertical-align:top;">The environment mode.
Defaults to <code>:production</code>, can also be <code>:development</code>
Defaults to <code>:development</code>, traditionally one of <code>:development</code> or <code>:production</code>
but any environment string can be provided. Custom environments will use the defaults of the
<code>:development</code> environment unless overridden.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -425,4 +427,4 @@ to avoid crashing the watcher in the case where the file has been removed.
self.icon = '/path/to/fail.jpg'
sticky!
}
end
end
4 changes: 2 additions & 2 deletions lib/compass/configuration/defaults.rb
Expand Up @@ -27,15 +27,15 @@ def default_environment
end

def default_output_style
if top_level.environment == :development
if top_level.environment != :production
:expanded
else
:compressed
end
end

def default_line_comments
top_level.environment == :development
top_level.environment != :production
end

def default_color_output
Expand Down
6 changes: 3 additions & 3 deletions lib/compass/exec/project_options_parser.rb
Expand Up @@ -44,9 +44,9 @@ def set_project_options(opts)
set_dir_or_path(:fonts, fonts_dir)
end

opts.on('-e ENV', '--environment ENV', [:development, :production], 'Use sensible defaults for your current environment.',
' One of: development (default), production') do |env|
self.options[:environment] = env
opts.on('-e ENV', '--environment ENV', 'Use sensible defaults for your current environment.',
' defaults to development') do |env|
self.options[:environment] = env || :development
end

opts.on('-s STYLE', '--output-style STYLE', [:nested, :expanded, :compact, :compressed], 'Select a CSS output mode.',
Expand Down
11 changes: 11 additions & 0 deletions test/integrations/compass_test.rb
Expand Up @@ -95,6 +95,17 @@ def test_env_in_production
end
end

def test_env_in_custom_env
within_project('envtest', lambda {|c| c.environment = :staging }) do |proj|
each_css_file(proj.css_path) do |css_file|
assert_no_errors css_file, 'envtest'
end
each_sass_file do |sass_file|
assert_renders_correctly sass_file, :ignore_charset => true, :environment => "staging"
end
end
end

def test_busted_image_urls
within_project('busted_image_urls') do |proj|
each_css_file(proj.css_path) do |css_file|
Expand Down