File: runner.rb

package info (click to toggle)
ruby-webpacker 5.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 1,472 kB
  • sloc: ruby: 1,626; javascript: 1,480; makefile: 4
file content (23 lines) | stat: -rw-r--r-- 783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Webpacker
  class Runner
    def self.run(argv)
      $stdout.sync = true

      new(argv).run
    end

    def initialize(argv)
      @argv = argv

      @app_path              = File.expand_path(".", Dir.pwd)
      @node_modules_bin_path = ENV["WEBPACKER_NODE_MODULES_BIN_PATH"] || `yarnpkg bin`.chomp
      @webpack_config        = File.join(@app_path, "config/webpack/#{ENV["NODE_ENV"]}.js")
      @webpacker_config      = File.join(@app_path, "config/webpacker.yml")

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