From acd440ae9337a1b97b6550dca46e4df1a1b771dc Mon Sep 17 00:00:00 2001 From: Kyle Plump Date: Mon, 29 Jul 2024 14:50:09 -0400 Subject: [PATCH 1/5] skip fork when not implemented --- lib/hanami/cli/commands/app/assets/command.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/hanami/cli/commands/app/assets/command.rb b/lib/hanami/cli/commands/app/assets/command.rb index f244f0be..2b89e5e3 100644 --- a/lib/hanami/cli/commands/app/assets/command.rb +++ b/lib/hanami/cli/commands/app/assets/command.rb @@ -85,6 +85,9 @@ def fork_child_assets_command(slice) Process.fork do cmd, *args = assets_command(slice) system_call.call(cmd, *args, out_prefix: "[#{slice.slice_name}] ") + rescue NotImplementedError + cmd, *args = assets_command(slice) + system_call.call(cmd, *args, out_prefix: "[#{slice.slice_name}] ") rescue Interrupt # When this has been interrupted (by the Signal.trap handler in #call), catch the # interrupt and exit cleanly, without showing the default full backtrace. From 27279af3661f1a123f03c2d56040fcaef43182b4 Mon Sep 17 00:00:00 2001 From: Kyle Plump Date: Mon, 29 Jul 2024 15:27:39 -0400 Subject: [PATCH 2/5] comment --- lib/hanami/cli/commands/app/assets/command.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/hanami/cli/commands/app/assets/command.rb b/lib/hanami/cli/commands/app/assets/command.rb index 2b89e5e3..3b2ddd73 100644 --- a/lib/hanami/cli/commands/app/assets/command.rb +++ b/lib/hanami/cli/commands/app/assets/command.rb @@ -11,7 +11,7 @@ module App module Assets # Base class for assets commands. # - # Finds slices with assets present (anything in an `assets/` dir), then forks a child + # Finds slices with assets present (anything in an `assets/` dir), then forks or spawns a child # process for each slice to run the assets command (`config/assets.js`) for the slice. # # Prefers the slice's own `config/assets.js` if present, otherwise falls back to the @@ -85,6 +85,8 @@ def fork_child_assets_command(slice) Process.fork do cmd, *args = assets_command(slice) system_call.call(cmd, *args, out_prefix: "[#{slice.slice_name}] ") + # Handle Process.fork not being implemented on non-POSIX OS's + # by only spawning a child process of the main process rescue NotImplementedError cmd, *args = assets_command(slice) system_call.call(cmd, *args, out_prefix: "[#{slice.slice_name}] ") From 45b875d8905f49675393bc8cd50a2e54fa3b93d1 Mon Sep 17 00:00:00 2001 From: Kyle Plump Date: Tue, 30 Jul 2024 14:28:26 -0400 Subject: [PATCH 3/5] fork assets into new thread as well --- lib/hanami/cli/commands/app/assets/command.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/hanami/cli/commands/app/assets/command.rb b/lib/hanami/cli/commands/app/assets/command.rb index 3b2ddd73..7bfe3257 100644 --- a/lib/hanami/cli/commands/app/assets/command.rb +++ b/lib/hanami/cli/commands/app/assets/command.rb @@ -88,8 +88,10 @@ def fork_child_assets_command(slice) # Handle Process.fork not being implemented on non-POSIX OS's # by only spawning a child process of the main process rescue NotImplementedError - cmd, *args = assets_command(slice) - system_call.call(cmd, *args, out_prefix: "[#{slice.slice_name}] ") + Thread.new do + cmd, *args = assets_command(slice) + system_call.call(cmd, *args, out_prefix: "[#{slice.slice_name}] ") + end rescue Interrupt # When this has been interrupted (by the Signal.trap handler in #call), catch the # interrupt and exit cleanly, without showing the default full backtrace. From caf6ff00e4316fb5e8c8f96b98444300f5e0d047 Mon Sep 17 00:00:00 2001 From: Kyle Plump Date: Thu, 7 Nov 2024 20:31:45 -0500 Subject: [PATCH 4/5] .bat win platform --- lib/hanami/cli/generators/gem/app.rb | 2 ++ lib/hanami/cli/generators/gem/app/dev.bat | 1 + 2 files changed, 3 insertions(+) create mode 100644 lib/hanami/cli/generators/gem/app/dev.bat diff --git a/lib/hanami/cli/generators/gem/app.rb b/lib/hanami/cli/generators/gem/app.rb index 2f68b95c..2b565942 100644 --- a/lib/hanami/cli/generators/gem/app.rb +++ b/lib/hanami/cli/generators/gem/app.rb @@ -46,6 +46,8 @@ def generate_app(app, context) # rubocop:disable Metrics/AbcSize fs.write("bin/dev", file("dev")) fs.chmod("bin/dev", 0o755) + fs.write("bin/dev.bat", file("dev.bat")) if Gem.win_platform? + fs.write("config/app.rb", t("app.erb", context)) fs.write("config/settings.rb", t("settings.erb", context)) fs.write("config/routes.rb", t("routes.erb", context)) diff --git a/lib/hanami/cli/generators/gem/app/dev.bat b/lib/hanami/cli/generators/gem/app/dev.bat new file mode 100644 index 00000000..9016fc36 --- /dev/null +++ b/lib/hanami/cli/generators/gem/app/dev.bat @@ -0,0 +1 @@ +@bash.exe "%~dpn0" %* \ No newline at end of file From ffd426ebce1e9ba12ec7764a891c31fa9edab5a0 Mon Sep 17 00:00:00 2001 From: Kyle Plump Date: Fri, 8 Nov 2024 13:02:37 -0500 Subject: [PATCH 5/5] gem --- lib/hanami/cli/generators/gem/app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hanami/cli/generators/gem/app.rb b/lib/hanami/cli/generators/gem/app.rb index 2b565942..4830da27 100644 --- a/lib/hanami/cli/generators/gem/app.rb +++ b/lib/hanami/cli/generators/gem/app.rb @@ -46,7 +46,7 @@ def generate_app(app, context) # rubocop:disable Metrics/AbcSize fs.write("bin/dev", file("dev")) fs.chmod("bin/dev", 0o755) - fs.write("bin/dev.bat", file("dev.bat")) if Gem.win_platform? + fs.write("bin/dev.bat", file("dev.bat")) if ::Gem.win_platform? fs.write("config/app.rb", t("app.erb", context)) fs.write("config/settings.rb", t("settings.erb", context))