lib/sewing_kit/webpack/compiler.rb in sewing_kit-0.28.0 vs lib/sewing_kit/webpack/compiler.rb in sewing_kit-0.29.1

- old
+ new

@@ -2,11 +2,25 @@ require 'sewing_kit/webpack/webpack' module SewingKit module Webpack class Compiler + class NodeNotInstalled < StandardError + def initialize + super( + "nodejs is not installed. " \ + "Try creating a `.buildpack` file in the root of the project with following content: + + https://github.com/heroku/heroku-buildpack-nodejs.git + https://github.com/heroku/heroku-buildpack-ruby.git + " + ) + end + end + def compile + raise NodeNotInstalled unless node_installed? raise NodeSewingKitNotRunnable, node_env unless File.exist?('node_modules/.bin/sewing-kit') result = Kernel.system( { 'NODE_ENV' => node_env }, *command, @@ -27,15 +41,19 @@ def command [ 'node_modules/.bin/sewing-kit', 'build', '--mode', - node_env + node_env, ].reject(&:empty?) end def node_env ENV['NODE_ENV'] || Rails.env.to_s + end + + def node_installed? + Kernel.system('node --version') end end end end