tailwindcss -w reads stdin, probably to detect stdin close.
When using binding.irb or debugger with tailwindcss-rails, some keystrokes are taken by tailwindcss and IRB/Debug can't read from stdin correctly. Keystroke disappears, and sometimes hangs up.
To not let tailwindcss watch command read stdin, we should use IO.popen(command, 'r+') instead of system(*command).
Workaround for https://github.com/rails/tailwindcss-rails/discussions/346
Reproduction code
watch_command = ['./node_modules/.bin/tailwindcss', '-w']
Thread.new do # same for `fork do`
system(*watch_command)
# IO.popen(watch_command, 'r+') do |io|
# IO.copy_stream(io, $stdout)
# end
puts 'command finished'
end
sleep 1
binding.irb
Side effect
Before this pull request, Ctrl-D will stop rails s. Closing stdin will stop tailwind, then puma will stop with a message Detected tailwind has gone away, stopping Puma...
After this change, Ctrl-D won't stop tailwind.
Description
tailwindcss -w
reads stdin, probably to detect stdin close. When using binding.irb or debugger with tailwindcss-rails, some keystrokes are taken by tailwindcss and IRB/Debug can't read from stdin correctly. Keystroke disappears, and sometimes hangs up. To not let tailwindcss watch command read stdin, we should useIO.popen(command, 'r+')
instead ofsystem(*command)
. Workaround for https://github.com/rails/tailwindcss-rails/discussions/346Reproduction code
Side effect
Before this pull request, Ctrl-D will stop
rails s
. Closing stdin will stop tailwind, then puma will stop with a messageDetected tailwind has gone away, stopping Puma...
After this change, Ctrl-D won't stop tailwind.