Skip to content

Commit edd90d5

Browse files
committed
Use IO.popen instead of system to avoid stdin read by tailwindcss watch command
`tailwindcss -w` reads stdin, probably to detect stdin close. When using binding.irb or debugger with tailwindcss-rails, some keystrokes are taken by tailwindcss. To not let tailwindcss watch command read stdin, we should use `IO.popen(command, 'r+')` instead of `system(*command)`. Workaround for #346
1 parent 828eacc commit edd90d5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/puma/plugin/tailwindcss.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ def start(launcher)
88
@puma_pid = $$
99
@tailwind_pid = fork do
1010
Thread.new { monitor_puma }
11-
system(*Tailwindcss::Commands.watch_command)
11+
# Using IO.popen(command, 'r+') will avoid watch_command read from $stdin.
12+
# If we use system(*command) instead, IRB and Debug can't read from $stdin
13+
# correctly bacause some keystrokes will be taken by watch_command.
14+
IO.popen(Tailwindcss::Commands.watch_command, 'r+') do |io|
15+
IO.copy_stream(io, $stdout)
16+
end
1217
end
1318

1419
launcher.events.on_stopped { stop_tailwind }

0 commit comments

Comments
 (0)