@@ -192,7 +192,7 @@ fn build_package<'a>(
192192/// can be marked with the type 'dev'. Which means that they may not be around in the distributed
193193/// NPM package. The file reader allows for this, just warns when this happens.
194194/// TODO -> Check wether we actually need the `fs::Metadata`
195- pub fn get_source_files ( dir : & String , source : & PackageSource ) -> AHashMap < String , fs:: Metadata > {
195+ pub fn get_source_files ( filter : & Option < regex :: Regex > , dir : & String , source : & PackageSource ) -> AHashMap < String , fs:: Metadata > {
196196 let mut map: AHashMap < String , fs:: Metadata > = AHashMap :: new ( ) ;
197197
198198 let ( recurse, type_) = match source {
@@ -206,7 +206,7 @@ pub fn get_source_files(dir: &String, source: &PackageSource) -> AHashMap<String
206206
207207 // don't include dev sources for now
208208 if type_ != & Some ( "dev" . to_string ( ) ) {
209- match structure_hashmap:: read_folders ( dir, recurse) {
209+ match structure_hashmap:: read_folders ( & filter , dir, recurse) {
210210 Ok ( files) => map. extend ( files) ,
211211 Err ( _e) if type_ == & Some ( "dev" . to_string ( ) ) => {
212212 println ! ( "Could not read folder: {dir}... Probably ok as type is dev" )
@@ -228,13 +228,13 @@ pub fn namespace_from_package_name(package_name: &str) -> String {
228228
229229/// This takes the tree of packages, and finds all the source files for each, adding them to the
230230/// respective packages.
231- fn extend_with_children ( mut build : AHashMap < String , Package > ) -> AHashMap < String , Package > {
231+ fn extend_with_children ( filter : & Option < regex :: Regex > , mut build : AHashMap < String , Package > ) -> AHashMap < String , Package > {
232232 for ( _key, value) in build. iter_mut ( ) {
233233 let mut map: AHashMap < String , fs:: Metadata > = AHashMap :: new ( ) ;
234234 value
235235 . source_folders
236236 . par_iter ( )
237- . map ( |( dir, source) | get_source_files ( dir, source) )
237+ . map ( |( dir, source) | get_source_files ( & filter , dir, source) )
238238 . collect :: < Vec < AHashMap < String , fs:: Metadata > > > ( )
239239 . into_iter ( )
240240 . for_each ( |source| map. extend ( source) ) ;
@@ -271,7 +271,7 @@ fn extend_with_children(mut build: AHashMap<String, Package>) -> AHashMap<String
271271/// 2. Take the (by then deduplicated) packages, and find all the '.re', '.res', '.ml' and
272272/// interface files.
273273/// The two step process is there to reduce IO overhead
274- pub fn make ( root_folder : & str ) -> AHashMap < String , Package > {
274+ pub fn make ( filter : & Option < regex :: Regex > , root_folder : & str ) -> AHashMap < String , Package > {
275275 /* The build_package get's called recursively. By using extend, we deduplicate all the packages
276276 * */
277277 let mut map: AHashMap < String , Package > = AHashMap :: new ( ) ;
@@ -281,7 +281,7 @@ pub fn make(root_folder: &str) -> AHashMap<String, Package> {
281281 build_package ( & mut map, bsconfig, & package_dir, root_folder, true ) ;
282282 /* Once we have the deduplicated packages, we can add the source files for each - to minimize
283283 * the IO */
284- let result = extend_with_children ( map) ;
284+ let result = extend_with_children ( & filter , map) ;
285285 result
286286 . values ( )
287287 . into_iter ( )
0 commit comments