Sha256: b6b93a72b8cb974891a3290d3c404af37b462f07fee3d307b6aea7d167172c79
Contents?: true
Size: 1.59 KB
Versions: 3
Compression:
Stored size: 1.59 KB
Contents
# frozen_string_literal: true 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, chdir: Rails.root.to_s, out: $stdout, err: $stderr ) unless result puts "sewing-kit compile failed with error code #{$CHILD_STATUS}" exit(1) end result end private def command [ 'node_modules/.bin/sewing-kit', 'build', '--mode', node_env, ].concat(options).reject(&:empty?) end def node_env ENV['NODE_ENV'] || Rails.env.to_s end def options build_options = SewingKit.configuration.build_options return [] unless build_options build_options.map { |key, value| ["--#{key.to_s.tr('_', '-')}", value.to_s] }.flatten end def node_installed? Kernel.system('node --version') end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sewing_kit-0.114.2 | lib/sewing_kit/webpack/compiler.rb |
sewing_kit-0.114.0 | lib/sewing_kit/webpack/compiler.rb |
sewing_kit-0.97.2 | lib/sewing_kit/webpack/compiler.rb |