Skip to content

Commit

Permalink
Use class instance variable for installing
Browse files Browse the repository at this point in the history
  • Loading branch information
justin808 committed Nov 13, 2021
1 parent ce7cdd7 commit eab7a02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/tasks/webpacker/install.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ bin_path = ENV["BUNDLE_BIN"] || Rails.root.join("bin")
namespace :webpacker do
desc "Install Webpacker in this application"
task install: [:check_node, :check_yarn] do |task|
@@webpacker_installing = true
Webpacker::Configuration.installing = true

prefix = task.name.split(/#|webpacker:install/).first

if Rails::VERSION::MAJOR >= 5
Expand Down
6 changes: 5 additions & 1 deletion lib/webpacker/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
require "active_support/core_ext/hash/indifferent_access"

class Webpacker::Configuration
class << self
attr_accessor :installing
end

attr_reader :root_path, :config_path, :env

def initialize(root_path:, config_path:, env:)
Expand Down Expand Up @@ -80,7 +84,7 @@ def load
end
config[env].deep_symbolize_keys
rescue Errno::ENOENT => e
if @@webpacker_installing
if self.class.installing
{}
else
raise "Webpacker configuration file not found #{config_path}. " \
Expand Down

0 comments on commit eab7a02

Please sign in to comment.