File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprocket
55## Master
66
77- Remove remaining support for Ruby < 2.4.[ #672 ] ( https://github.com/rails/sprockets/pull/672 )
8+ - Find all asset by a regexp filemask or a filepath.[ #698 ] ( https://github.com/rails/sprockets/pull/698 )
89
910## 4.0.2
1011
Original file line number Diff line number Diff line change @@ -129,6 +129,25 @@ def find_asset!(*args)
129129 end
130130 end
131131
132+ # Find all asset by a regexp filemask or a filepath.
133+ def find_all_assets ( *args , &block )
134+ paths = config [ :paths ]
135+
136+ args . each do |arg |
137+ if arg . is_a? ( Regexp )
138+ paths . each do |path |
139+ files = Dir [ "#{ path } /*" ] . select { |file | arg =~ file }
140+
141+ files . each do |file |
142+ find_all_linked_assets ( file , &block )
143+ end
144+ end
145+ else
146+ find_all_linked_assets ( arg , &block )
147+ end
148+ end
149+ end
150+
132151 # Pretty inspect
133152 def inspect
134153 "#<#{ self . class } :0x#{ object_id . to_s ( 16 ) } " +
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ def find(*args)
122122 environment = self . environment . cached
123123 promises = args . flatten . map do |path |
124124 Concurrent ::Promise . execute ( executor : executor ) do
125- environment . find_all_linked_assets ( path ) do |asset |
125+ environment . find_all_assets ( path ) do |asset |
126126 yield asset
127127 end
128128 end
You can’t perform that action at this time.
0 commit comments