File tree 2 files changed +17
-4
lines changed
2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -25,11 +25,17 @@ def executable(
25
25
MESSAGE
26
26
end
27
27
28
- exe_path = Dir . glob ( File . expand_path ( File . join ( exe_path , "*" , "tailwindcss" ) ) ) . find do |f |
29
- Gem ::Platform . match ( Gem ::Platform . new ( File . basename ( File . dirname ( f ) ) ) )
28
+ # Let the user override the executable path with an environment variable
29
+ # Useful for when running under Nix
30
+ exe_file = ENV [ "TAILWINDCSS_RAILS_EXECUTABLE_PATH" ]
31
+
32
+ if exe_file . nil? || exe_file . empty?
33
+ exe_file = Dir . glob ( File . expand_path ( File . join ( exe_path , "*" , "tailwindcss" ) ) ) . find do |f |
34
+ Gem ::Platform . match ( Gem ::Platform . new ( File . basename ( File . dirname ( f ) ) ) )
35
+ end
30
36
end
31
37
32
- if exe_path . nil?
38
+ if exe_file . nil? || exe_file . empty ?
33
39
raise ExecutableNotFoundException , <<~MESSAGE
34
40
Cannot find the tailwindcss executable for #{ platform } in #{ exe_path }
35
41
@@ -52,7 +58,7 @@ def executable(
52
58
MESSAGE
53
59
end
54
60
55
- exe_path
61
+ exe_file
56
62
end
57
63
58
64
def compile_command ( debug : false , **kwargs )
Original file line number Diff line number Diff line change @@ -26,6 +26,13 @@ def mock_exe_directory(platform)
26
26
end
27
27
end
28
28
29
+ test ".executable accepts an override through the TAILWINDCSS_RAILS_EXECUTABLE_PATH environment variable" do
30
+ filename = "/nix/store/li4jwsd16y68yjyznbffaf98jccipg36-tailwindcss-3.2.7/bin/tailwindcss"
31
+ ENV [ "TAILWINDCSS_RAILS_EXECUTABLE_PATH" ] = filename
32
+ assert_equal ( filename , Tailwindcss ::Commands . executable )
33
+ ENV [ "TAILWINDCSS_RAILS_EXECUTABLE_PATH" ] = ""
34
+ end
35
+
29
36
test ".executable raises UnsupportedPlatformException when we're not on a supported platform" do
30
37
Gem ::Platform . stub ( :match , false ) do # nothing is supported
31
38
assert_raises ( Tailwindcss ::Commands ::UnsupportedPlatformException ) do
You can’t perform that action at this time.
0 commit comments