tailwindcss-rails 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 286396c8100fdd62be9b92948d5ca9d7fa08f8b5747451f40f24405018ffe047
4
- data.tar.gz: 937b6afa7441d470d2a0d8f10a21a409eff863d82f6c723ebe07a52d6d4ec462
3
+ metadata.gz: f267a171a6a28b6a5f433e4957f72f4edf6c027cfd386c3aa1ed96fc6a2eb6f6
4
+ data.tar.gz: 025b01f752fafb76b48717d2ce07b03bd23fed1106a4ca2dafe2bea850538341
5
5
  SHA512:
6
- metadata.gz: b1e3c2e086f51999a4541aba0de0a125c052e730a2fb13d302e00f4e688444abbb4bb1ba0858b4e6267951e8be70e7d37060558a6100c2fed37b71d399e23bb0
7
- data.tar.gz: 6e1f8a07ec3502513a9cbadf05e5f2e51ffcd0d23415a3c1ff3d129994e43ffd21994194c84d0730fe93bac2c9e9a41cc34f1f282a085aca9dddd95abd09ad0c
6
+ metadata.gz: d04850588508ebf0adc736879845b1cb8d6f992768487ed9274f752388183280860d75640096953a2dc1dbac9be32730962ccd9292c04487692baecbe8d5c1ed
7
+ data.tar.gz: 8b008e2b24fcfd5e238155ae456ca1249c3d7767fa6b96db34349173493291dfcdce20dffc3d97799322c6669f77b77bfd3a52723a3d72de9f940b1c6a690678
@@ -0,0 +1,59 @@
1
+ module Tailwindcss
2
+ # Runs a child process and forwards stop signals (INT/TERM) to it, blocking
3
+ # until it exits, so a process manager that signals this process directly
4
+ # (e.g. foreman) doesn't leave the child orphaned. Shaped like
5
+ # +Process.spawn+/+Kernel#system+: it takes an +env+ hash followed by the
6
+ # command.
7
+ module ProcessRunner
8
+ # Signals we forward to the spawned process so it shuts down with us instead
9
+ # of being orphaned.
10
+ FORWARDED_SIGNALS = %w[INT TERM].freeze
11
+
12
+ class << self
13
+ # Spawn +command+ with +env+ and block until it exits, forwarding INT
14
+ # (Ctrl-C) and TERM (e.g. foreman shutdown) to it so a process manager
15
+ # that signals us directly doesn't leave an orphaned child behind.
16
+ # Restores the previous signal handlers before returning so the
17
+ # process-global traps aren't left changed. Returns the name of the signal
18
+ # that was received (e.g. "TERM"), or nil if the child exited on its own.
19
+ def spawn_and_wait(env, *command)
20
+ pid = nil
21
+ received_signal = nil
22
+ previous_traps = {}
23
+
24
+ forward_signal = ->(signal) do
25
+ if pid
26
+ Process.kill(signal, pid)
27
+ end
28
+ rescue Errno::ESRCH
29
+ # the child already exited
30
+ end
31
+
32
+ # Trap immediately before spawning. If a signal lands before pid is
33
+ # assigned, remember it and forward it once the child exists.
34
+ FORWARDED_SIGNALS.each do |signal|
35
+ previous_traps[signal] = trap(signal) do
36
+ received_signal ||= signal
37
+ forward_signal.call(signal)
38
+ end
39
+ end
40
+
41
+ pid = Process.spawn(env, *command)
42
+ # If a signal arrived during spawn (before pid was set), the handler
43
+ # couldn't forward it yet, so forward it now.
44
+ if received_signal
45
+ forward_signal.call(received_signal)
46
+ end
47
+ Process.wait(pid)
48
+ # Drop the pid so a late signal can't kill a process that reused it.
49
+ pid = nil
50
+
51
+ received_signal
52
+ ensure
53
+ previous_traps.each do |signal, previous_trap|
54
+ trap(signal, previous_trap)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,3 +1,3 @@
1
1
  module Tailwindcss
2
- VERSION = "4.5.0"
2
+ VERSION = "4.6.0"
3
3
  end
@@ -5,3 +5,4 @@ require_relative "tailwindcss/version"
5
5
  require_relative "tailwindcss/engines"
6
6
  require_relative "tailwindcss/engine"
7
7
  require_relative "tailwindcss/commands"
8
+ require_relative "tailwindcss/process_runner"
data/lib/tasks/build.rake CHANGED
@@ -23,9 +23,8 @@ namespace :tailwindcss do
23
23
  env = Tailwindcss::Commands.command_env(verbose: verbose)
24
24
  puts "Running: #{Shellwords.join(command)}" if verbose
25
25
 
26
- system(env, *command)
27
- rescue Interrupt
28
- puts "Received interrupt, exiting tailwindcss:watch" if args.extras.include?("verbose")
26
+ received_signal = Tailwindcss::ProcessRunner.spawn_and_wait(env, *command)
27
+ puts "Received #{received_signal}, exiting tailwindcss:watch" if verbose && received_signal
29
28
  end
30
29
 
31
30
  desc "Create Tailwind CSS entry point files for Rails Engines"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tailwindcss-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.0
4
+ version: 4.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -74,6 +74,7 @@ files:
74
74
  - lib/tailwindcss/commands.rb
75
75
  - lib/tailwindcss/engine.rb
76
76
  - lib/tailwindcss/engines.rb
77
+ - lib/tailwindcss/process_runner.rb
77
78
  - lib/tailwindcss/upstream.rb
78
79
  - lib/tailwindcss/version.rb
79
80
  - lib/tasks/build.rake