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

Already on GitHub? Sign in to your account

Allow custom environments #1322

Open
wants to merge 5 commits into
from
@@ -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>
@@ -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
@@ -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
@@ -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.',
@@ -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|