class WebpackerConfigShower::Runner

Public Class Methods

run(argv) click to toggle source
Calls superclass method
# File lib/webpacker_config_shower.rb, line 7
def self.run(argv)
  ENV["NODE_ENV"] ||= Rails.env
  super
end

Public Instance Methods

run() click to toggle source
# File lib/webpacker_config_shower.rb, line 12
def run
  cmd = [
    "node",
    "-e",
    *[
      "const conf = require('#{@webpack_config}')",
      "const { format } = require('util')",
      "console.log(format('%j', conf))",
    ].join(';')
  ]

  Dir.chdir(@app_path) do
    _, stdout, _ = *Open3.popen3(*cmd)
    puts JSON.pretty_generate(JSON.parse(stdout.read))
  end
end