lib/sewing_kit/webpack/dev.rb in sewing_kit-0.28.0 vs lib/sewing_kit/webpack/dev.rb in sewing_kit-0.29.1

- old
+ new

@@ -1,6 +1,9 @@ # frozen_string_literal: true + +require 'English' + module SewingKit module Webpack class Dev class NodeSewingKitNotInstalled < StandardError def initialize @@ -13,10 +16,11 @@ attr_accessor :pid def start @pid = spawn + at_exit { handle_exit } detach end private @@ -34,9 +38,16 @@ 'dev', chdir: Rails.root.to_s, out: $stdout, err: $stderr, ) || exit(1) + end + + def handle_exit + return if $ERROR_INFO.nil? + Process.kill 'SIGTERM', pid + rescue Errno::ESRCH + nil end def detach Process.detach pid end