Skip to content

Commit

Permalink
Reuse the regex in common_component_to_path
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyr committed Jul 20, 2022
1 parent 752bafd commit 0287fa4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/react_on_rails/packs_generator.rb
Expand Up @@ -4,7 +4,7 @@

module ReactOnRails
class PacksGenerator
ENDS_WITH_CLIENT_OR_SERVER_REGEX = /\.server$|\.client$/.freeze
CONTAINS_CLIENT_OR_SERVER_REGEX = /\.server|\.client/.freeze

def self.generate
return unless components_directory.present?
Expand Down Expand Up @@ -128,7 +128,7 @@ def self.generated_pack_path(file_path)
def self.component_name(file_path)
basename = File.basename(file_path, File.extname(file_path))

basename.sub(ENDS_WITH_CLIENT_OR_SERVER_REGEX, "")
basename.sub(CONTAINS_CLIENT_OR_SERVER_REGEX, "")
end

def self.component_name_to_path(paths)
Expand All @@ -137,7 +137,7 @@ def self.component_name_to_path(paths)

def self.common_component_to_path
common_components_paths = Dir.glob("#{components_search_path}/*").reject do |f|
f.include?(".client.") || f.include?(".server.")
CONTAINS_CLIENT_OR_SERVER_REGEX.match?(f)
end
component_name_to_path(common_components_paths)
end
Expand Down

0 comments on commit 0287fa4

Please sign in to comment.