Skip to content

Commit

Permalink
Fix Rubocop Error
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkitkkr committed Jan 26, 2023
1 parent a4bbcac commit ea1769b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 6 additions & 4 deletions lib/react_on_rails/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def react_component(component_name, options = {})
end

def load_pack_for_component(component_name)
component_pack_file_path = "#{generated_components_pack(component_name)}.#{PacksGenerator.generated_pack_extension}"
is_component_pack_present = File.exist?(component_pack_file_path)

is_component_pack_present = File.exist?(generated_components_pack_path(component_name))
is_development = ENV["RAILS_ENV"] == "development"

if is_development && !is_component_pack_present
Expand All @@ -109,8 +109,10 @@ def load_pack_for_component(component_name)
append_stylesheet_pack_tag "generated/#{component_name}"
end

def generated_components_pack(component_name)
"#{ReactOnRails::WebpackerUtils.webpacker_source_entry_path}/generated/#{component_name}"
def generated_components_pack_path(component_name)
extension = PacksGenerator.generated_pack_extension

"#{ReactOnRails::WebpackerUtils.webpacker_source_entry_path}/generated/#{component_name}.#{extension}"
end

# react_component_hash is used to return multiple HTML strings for server rendering, such as for
Expand Down
12 changes: 6 additions & 6 deletions lib/react_on_rails/packs_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ class PacksGenerator
MINIMUM_SHAKAPACKER_MAJOR_VERSION = 6
MINIMUM_SHAKAPACKER_MINOR_VERSION = 5
MINIMUM_SHAKAPACKER_PATCH_VERSION = 1
GENERATED_PACK_EXTENSION = "js".freeze
self.GENERATED_PACK_EXTENSION = "js"

class << self
attr_accessor :GENERATED_PACK_EXTENSION
end

def self.generate
packs_generator = PacksGenerator.new
Expand All @@ -21,10 +25,6 @@ def self.raise_nested_entries_disabled
packs_generator.raise_nested_entries_disabled
end

def self.generated_pack_extension
GENERATED_PACK_EXTENSION
end

def verify_setup_and_generate_packs
return unless components_subdirectory.present?

Expand Down Expand Up @@ -157,7 +157,7 @@ def relative_path(from, to)
end

def generated_pack_path(file_path)
"#{generated_packs_directory_path}/#{component_name(file_path)}.#{generated_pack_extension}"
"#{generated_packs_directory_path}/#{component_name(file_path)}.#{GENERATED_PACK_EXTENSION}"
end

def component_name(file_path)
Expand Down

0 comments on commit ea1769b

Please sign in to comment.