lib/sewing_kit/webpack/dev.rb in sewing_kit-0.94.0 vs lib/sewing_kit/webpack/dev.rb in sewing_kit-0.95.0
- old
+ new
@@ -1,7 +1,6 @@
# frozen_string_literal: true
-
require 'English'
module SewingKit
module Webpack
class Dev
@@ -23,21 +22,17 @@
end
private
def spawn
- sewing_kit_bin = SewingKit.configuration.dev_server_sewing_kit_bin
- raise NodeSewingKitNotInstalled unless File.exist?(sewing_kit_bin)
-
Kernel.spawn(
{
'NODE_ENV' => 'development',
'BLUEBIRD_DEBUG' => '0',
'BLUEBIRD_LONG_STACK_TRACES' => '0',
},
- sewing_kit_bin,
- 'dev',
+ command,
chdir: Rails.root.to_s,
out: $stdout,
err: $stderr,
) || exit(1)
end
@@ -49,9 +44,55 @@
nil
end
def detach
Process.detach pid
+ end
+
+ def command
+ command_list = [
+ sewing_kit_bin,
+ 'dev',
+ '--logLevel',
+ log_level,
+ ]
+
+ if debug_mode?
+ command_list.push(['--debug'])
+ end
+
+ command_list.join(' ')
+ end
+
+ def sewing_kit_bin
+ bin = SewingKit.configuration.dev_server_sewing_kit_bin
+ raise NodeSewingKitNotInstalled unless File.exist?(bin)
+ bin
+ end
+
+ def log_level
+ if SewingKit.configuration.log_level == :inherit
+ log_level_from_rails
+ else
+ SewingKit.configuration.log_level.to_s
+ end
+ end
+
+ def log_level_from_rails
+ case Rails.logger.level
+ when 0
+ :debug
+ when 1
+ :info
+ when 2
+ :warn
+ else
+ :error
+ end
+ end
+
+ def debug_mode?
+ !ENV['SK_DEBUG'].nil?
end
end
end
end