@@ -221,6 +221,7 @@ impl ResourcePathsIter<'_> {
221221
222222 fn next_pattern ( & mut self ) -> Option < crate :: Result < Resource > > {
223223 self . current_dest = None ;
224+ self . current_iter = None ;
224225
225226 let pattern = match & mut self . pattern_iter {
226227 PatternIter :: Slice ( iter) => iter. next ( ) ?,
@@ -237,10 +238,10 @@ impl ResourcePathsIter<'_> {
237238 Err ( error) => return Some ( Err ( error. into ( ) ) ) ,
238239 } ;
239240 match self . next_current_iter ( ) {
240- Some ( r) => return Some ( r) ,
241+ Some ( r) => Some ( r) ,
241242 None => {
242243 self . current_iter = None ;
243- return Some ( Err ( crate :: Error :: GlobPathNotFound ( pattern. clone ( ) ) ) ) ;
244+ Some ( Err ( crate :: Error :: GlobPathNotFound ( pattern. clone ( ) ) ) )
244245 }
245246 }
246247 } else {
@@ -257,12 +258,12 @@ impl ResourcePathsIter<'_> {
257258 None
258259 } ,
259260 } ) ;
261+ // If the directory is empty, skip and continue to the next pattern
262+ self . next_current_iter ( ) . or_else ( || self . next_pattern ( ) )
260263 } else {
261- return Some ( self . resource_from_path ( path) ) ;
264+ Some ( self . resource_from_path ( path) )
262265 }
263266 }
264-
265- self . next_current_iter ( )
266267 }
267268}
268269
@@ -358,6 +359,7 @@ mod tests {
358359 fs:: create_dir_all ( path. parent ( ) . unwrap ( ) ) . unwrap ( ) ;
359360 fs:: write ( path, "" ) . unwrap ( ) ;
360361 }
362+ fs:: create_dir_all ( "empty-directory" ) . unwrap ( ) ;
361363 }
362364
363365 fn resources_map ( literal : & [ ( & str , & str ) ] ) -> HashMap < String , String > {
@@ -377,6 +379,8 @@ mod tests {
377379
378380 let resources = ResourcePaths :: new (
379381 & [
382+ // `empty-directory` should not affect anything
383+ "../empty-directory" . into ( ) ,
380384 "../src/script.js" . into ( ) ,
381385 "../src/assets" . into ( ) ,
382386 "../src/index.html" . into ( ) ,
0 commit comments