Skip to content

Commit a1b3757

Browse files
r-sierraflavorjones
authored andcommitted
Add TAILWINDCSS_DEBUG environment variable
1 parent 5ff2c27 commit a1b3757

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

lib/tailwindcss/commands.rb

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +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"])
78
rails_root = defined?(Rails) ? Rails.root : Pathname.new(Dir.pwd)
89

910
command = [

test/lib/tailwindcss/commands_test.rb

+28
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,34 @@ def setup
3333
end
3434
end
3535

36+
test ".compile_command debug environment variable" do
37+
begin
38+
Rails.stub(:root, File) do # Rails.root won't work in this test suite
39+
ENV["TAILWINDCSS_DEBUG"] = "0"
40+
actual = Tailwindcss::Commands.compile_command
41+
assert_kind_of(Array, actual)
42+
assert_includes(actual, "--minify")
43+
44+
ENV["TAILWINDCSS_DEBUG"] = "1"
45+
actual = Tailwindcss::Commands.compile_command
46+
assert_kind_of(Array, actual)
47+
refute_includes(actual, "--minify")
48+
49+
ENV["TAILWINDCSS_DEBUG"] = "false"
50+
actual = Tailwindcss::Commands.compile_command
51+
assert_kind_of(Array, actual)
52+
assert_includes(actual, "--minify")
53+
54+
ENV["TAILWINDCSS_DEBUG"] = "true"
55+
actual = Tailwindcss::Commands.compile_command
56+
assert_kind_of(Array, actual)
57+
refute_includes(actual, "--minify")
58+
end
59+
ensure
60+
ENV.delete('TAILWINDCSS_DEBUG')
61+
end
62+
end
63+
3664
test ".compile_command when Rails compression is on" do
3765
Rails.stub(:root, File) do # Rails.root won't work in this test suite
3866
Tailwindcss::Commands.stub(:rails_css_compressor?, true) do

0 commit comments

Comments
 (0)