# frozen_string_literal: true module SewingKit module Webpack class Dev class NodeSewingKitNotInstalled < StandardError def initialize super( "sewing-kit is not installed. " \ "Try `yarn add --dev @shopify/sewing-kit`" ) end end attr_accessor :pid def start @pid = spawn detach end private def spawn sewing_kit_bin = 'node_modules/.bin/sewing-kit' 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', chdir: Rails.root.to_s, out: $stdout, err: $stderr, ) || exit(1) end def detach Process.detach pid end end end end