Skip to content

Commit e588387

Browse files
committed
ENV var should take precedence over command argument
1 parent 3a48a83 commit e588387

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Diff for: README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ The `tailwindcss:build` task is automatically attached to the `test:prepare` Rak
289289
If you want unminified assets, you can:
290290
291291
- pass a `debug` argument to the rake task, i.e. `rails tailwindcss:build[debug]` or `rails tailwindcss:watch[debug]`.
292-
- set an environment variable named `TAILWINDCSS_DEBUG` with a value of `true` or `1`
292+
- set an environment variable named `TAILWINDCSS_DEBUG` with a non-blank value
293+
294+
If both values are set, the environment variable will take precedence over the rake task argument.
293295
294296
### Live rebuild
295297

Diff for: lib/tailwindcss/commands.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Tailwindcss
44
module Commands
55
class << self
66
def compile_command(debug: false, **kwargs)
7-
debug ||= ["true", "1"].include?(ENV["TAILWINDCSS_DEBUG"])
7+
debug = ENV["TAILWINDCSS_DEBUG"].present? unless ENV["TAILWINDCSS_DEBUG"].nil?
88
rails_root = defined?(Rails) ? Rails.root : Pathname.new(Dir.pwd)
99

1010
command = [

Diff for: test/lib/tailwindcss/commands_test.rb

+6-8
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,21 @@ def setup
3636
test ".compile_command debug environment variable" do
3737
begin
3838
Rails.stub(:root, File) do # Rails.root won't work in this test suite
39-
ENV["TAILWINDCSS_DEBUG"] = "0"
39+
ENV["TAILWINDCSS_DEBUG"] = ""
4040
actual = Tailwindcss::Commands.compile_command
4141
assert_kind_of(Array, actual)
4242
assert_includes(actual, "--minify")
4343

44-
ENV["TAILWINDCSS_DEBUG"] = "1"
45-
actual = Tailwindcss::Commands.compile_command
44+
actual = Tailwindcss::Commands.compile_command(debug: true)
4645
assert_kind_of(Array, actual)
47-
refute_includes(actual, "--minify")
46+
assert_includes(actual, "--minify")
4847

49-
ENV["TAILWINDCSS_DEBUG"] = "false"
48+
ENV["TAILWINDCSS_DEBUG"] = "any non-blank value"
5049
actual = Tailwindcss::Commands.compile_command
5150
assert_kind_of(Array, actual)
52-
assert_includes(actual, "--minify")
51+
refute_includes(actual, "--minify")
5352

54-
ENV["TAILWINDCSS_DEBUG"] = "true"
55-
actual = Tailwindcss::Commands.compile_command
53+
actual = Tailwindcss::Commands.compile_command(debug: true)
5654
assert_kind_of(Array, actual)
5755
refute_includes(actual, "--minify")
5856
end

0 commit comments

Comments
 (0)