lib/sewing_kit/webpack/dev.rb in sewing_kit-0.130.0 vs lib/sewing_kit/webpack/dev.rb in sewing_kit-0.130.1

- old
+ new

@@ -1,16 +1,17 @@ # frozen_string_literal: true -require 'English' +require "English" + module SewingKit module Webpack class Dev class NodeSewingKitNotInstalled < StandardError def initialize super( "sewing-kit is not installed. " \ - "Try `yarn add @shopify/sewing-kit`" + "Try `yarn add @shopify/sewing-kit`" ) end end attr_accessor :pid @@ -24,58 +25,60 @@ private def spawn Kernel.spawn( { - 'NODE_ENV' => 'development', - 'BLUEBIRD_DEBUG' => '0', - 'BLUEBIRD_LONG_STACK_TRACES' => '0', - 'FORCE_COLOR' => 'true', + "NODE_ENV" => "development", + "BLUEBIRD_DEBUG" => "0", + "BLUEBIRD_LONG_STACK_TRACES" => "0", + "FORCE_COLOR" => "true", }, command, chdir: Rails.root.to_s, out: $stdout, err: $stderr, ) || exit(1) end def handle_exit return if $ERROR_INFO.nil? - Process.kill('SIGTERM', pid) + + Process.kill("SIGTERM", pid) rescue Errno::ESRCH nil end def detach Process.detach(pid) end def command command_list = [ - 'node', + "node", heap_config, sewing_kit_bin, - 'dev', - '--log-level', + "dev", + "--log-level", log_level, ].compact.concat(options) if debug_mode? - command_list.push(['--debug']) + command_list.push(["--debug"]) end - command_list.join(' ') + command_list.join(" ") end def heap_config heap_size = SewingKit.configuration.development_options[:heap] return "--max-old-space-size=#{heap_size}" if heap_size 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 @@ -89,11 +92,11 @@ development_options = SewingKit.configuration.development_options || {} focus = focus_sections development_options .reject { |key| key == :heap } - .map { |key, value| ["--#{key.to_s.tr('_', '-')}", value.to_s] }.flatten + focus.flatten + .map { |key, value| ["--#{key.to_s.tr("_", "-")}", value.to_s] }.flatten + focus.flatten end def log_level_from_rails case Rails.logger.level when 0 @@ -106,17 +109,17 @@ :error end end def debug_mode? - !ENV['SK_DEBUG'].nil? + !ENV["SK_DEBUG"].nil? end def focus_sections - return [] if ENV['SK_FOCUS'].nil? + return [] if ENV["SK_FOCUS"].nil? - ENV['SK_FOCUS'] - .split(',') + ENV["SK_FOCUS"] + .split(",") .map { |section| ["--focus", section] } end end end end