@@ -268,7 +268,7 @@ fn expand_file_to_parcels(
268268 let paths = glob:: glob ( & expansion_context. to_absolute ( pattern) ) ?;
269269 let parcels = paths
270270 . into_iter ( )
271- . map ( |p| try_convert_one_match_to_parcel ( p, expansion_context, member_of) )
271+ . filter_map ( |p| try_convert_one_match_to_parcel ( p, expansion_context, member_of) )
272272 . collect :: < anyhow:: Result < Vec < _ > > > ( ) ?;
273273 let warned_parcels = if parcels. is_empty ( ) {
274274 Warned :: from ( ( parcels, format ! ( "No files matched pattern {}" , pattern) ) )
@@ -282,19 +282,23 @@ fn try_convert_one_match_to_parcel(
282282 path : Result < PathBuf , GlobError > ,
283283 expansion_context : & ExpansionContext ,
284284 member_of : & str ,
285- ) -> anyhow:: Result < Parcel > {
285+ ) -> Option < anyhow:: Result < Parcel > > {
286286 match path {
287- Err ( e) => Err ( anyhow:: anyhow!( "Couldn't expand pattern: {}" , e) ) ,
287+ Err ( e) => Some ( Err ( anyhow:: anyhow!( "Couldn't expand pattern: {}" , e) ) ) ,
288288 Ok ( path) => {
289- let features = vec ! [ ( "file" , "true" ) ] ;
290- convert_one_match_to_parcel (
291- path,
292- expansion_context,
293- features,
294- None ,
295- Some ( member_of) ,
296- None ,
297- )
289+ if path. is_dir ( ) {
290+ None
291+ } else {
292+ let features = vec ! [ ( "file" , "true" ) ] ;
293+ Some ( convert_one_match_to_parcel (
294+ path,
295+ expansion_context,
296+ features,
297+ None ,
298+ Some ( member_of) ,
299+ None ,
300+ ) )
301+ }
298302 }
299303 }
300304}
@@ -972,6 +976,23 @@ mod test {
972976 assert_eq ! ( 0 , count) ;
973977 }
974978
979+ #[ test]
980+ fn test_finds_assets_in_nested_subdirectories ( ) {
981+ let invoice = expand_test_invoice ( "nesttest" ) . unwrap ( ) ;
982+ let assets = invoice
983+ . parcel
984+ . unwrap ( )
985+ . iter ( )
986+ . filter ( |parcel| parcel. member_of ( "out/fake.wasm-files" ) )
987+ . map ( |parcel| parcel. label . name . clone ( ) )
988+ . collect_vec ( ) ;
989+ assert_eq ! ( 4 , assets. len( ) ) ;
990+ assert ! ( assets. contains( & "assets/scripts/justsome.json" . to_owned( ) ) ) ;
991+ assert ! ( assets. contains( & "assets/scripts/real.js" . to_owned( ) ) ) ;
992+ assert ! ( assets. contains( & "assets/styles/css/suspicious.css" . to_owned( ) ) ) ;
993+ assert ! ( assets. contains( & "assets/styles/sass/iffy.sass" . to_owned( ) ) ) ;
994+ }
995+
975996 #[ test]
976997 fn test_if_file_does_not_exist_then_no_asset_parcels ( ) {
977998 // TODO: I feel like this should be an error
0 commit comments