# frozen_string_literal: true module SewingKit module Webpack class Server class DefaultEntrypointMissing < StandardError def initialize super( "Default entrypoint build/server/main.js is missing." ) end end def start raise DefaultEntrypointMissing unless File.exist?(default_entrypoint) result = Kernel.system( {}, *command, chdir: Rails.root.to_s, out: $stdout, err: $stderr ) unless result puts "sewing_kit:server:start failed" exit(1) end result end private def command command_list = [ 'node', default_entrypoint, ].compact command_list.join(' ') end def default_entrypoint 'build/server/main.js' end end end end