Class: Shakapacker::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/shakapacker/runner.rb

Direct Known Subclasses

DevServerRunner, WebpackRunner

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Runner

Returns a new instance of Runner.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/shakapacker/runner.rb', line 13

def initialize(argv)
  @argv = argv

  @app_path              = File.expand_path(".", Dir.pwd)
  @webpack_config        = File.join(@app_path, "config/webpack/webpack.config.js")
  @shakapacker_config    = ENV["SHAKAPACKER_CONFIG"] || File.join(@app_path, "config/shakapacker.yml")

  unless File.exist?(@webpack_config)
    $stderr.puts "webpack config #{@webpack_config} not found, please run 'bundle exec rails shakapacker:install' to install Shakapacker with default configs or add the missing config file for your custom environment."
    exit!
  end

  Shakapacker::Utils::Manager.error_unless_package_manager_is_obvious!
end

Class Method Details

.run(argv) ⇒ Object



7
8
9
10
11
# File 'lib/shakapacker/runner.rb', line 7

def self.run(argv)
  $stdout.sync = true
  ENV["NODE_ENV"] ||= (ENV["RAILS_ENV"] == "production") ? "production" : "development"
  new(argv).run
end

Instance Method Details

#package_jsonObject



28
29
30
# File 'lib/shakapacker/runner.rb', line 28

def package_json
  @package_json ||= PackageJson.read(@app_path)
end