module SewingKit module Webpack class NodeSewingKitNotInstalled < StandardError def initialize() super( "sewing-kit is not available. " + "Please add `@shopify/sewing-kit` to package.json's `devDependencies`, " + "and run `yarn install`." ) end end class Dev attr_accessor :pid def start @pid = spawn detach end private def spawn sewing_kit_bin = 'node_modules/.bin/sewing-kit' raise NodeSewingKitNotInstalled.new unless File.exist?(sewing_kit_bin) Kernel.spawn( { 'NODE_ENV' => 'development', 'BLUEBIRD_DEBUG' => '0', 'BLUEBIRD_LONG_STACK_TRACES' => '0', }, sewing_kit_bin, 'dev', chdir: Rails.root.to_s, out: $stdout, err: $stderr, ) || exit(1) end def detach Process.detach pid end end end end