Sha256: 27aba016db4c044c1d61eda3497cfc8d331764dcb77e65959cfa56d543860b4b

Contents?: true

Size: 911 Bytes

Versions: 7

Compression:

Stored size: 911 Bytes

Contents

# 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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sewing_kit-0.130.0 lib/sewing_kit/webpack/server.rb
sewing_kit-0.129.0 lib/sewing_kit/webpack/server.rb
sewing_kit-0.128.0 lib/sewing_kit/webpack/server.rb
sewing_kit-0.127.0 lib/sewing_kit/webpack/server.rb
sewing_kit-0.126.0 lib/sewing_kit/webpack/server.rb
sewing_kit-0.125.0 lib/sewing_kit/webpack/server.rb
sewing_kit-0.124.0 lib/sewing_kit/webpack/server.rb