@@ -374,7 +374,7 @@ fn flatten_dependencies(dependencies: Vec<Dependency>) -> Vec<Dependency> {
374
374
flattened
375
375
}
376
376
377
- fn read_package_name ( package_dir : & str ) -> Result < String > {
377
+ pub fn read_package_name ( package_dir : & str ) -> Result < String > {
378
378
let package_json_path = if package_dir. is_empty ( ) {
379
379
"package.json" . to_string ( )
380
380
} else {
@@ -415,8 +415,10 @@ fn make_package(config: config::Config, package_path: &str, is_pinned_dep: bool,
415
415
}
416
416
} ;
417
417
418
+ let package_name = read_package_name ( package_path) . expect ( "Could not read package name" ) ;
419
+ println ! ( "creating package: {:?}" , package_name) ;
418
420
Package {
419
- name : read_package_name ( package_path ) . expect ( "Could not read package name" ) ,
421
+ name : package_name ,
420
422
config : config. to_owned ( ) ,
421
423
source_folders,
422
424
source_files : None ,
@@ -444,10 +446,8 @@ fn read_packages(
444
446
445
447
// Store all packages and completely deduplicate them
446
448
let mut map: AHashMap < String , Package > = AHashMap :: new ( ) ;
447
- map. insert (
448
- root_config. name . to_owned ( ) ,
449
- make_package ( root_config. to_owned ( ) , project_root, false , true ) ,
450
- ) ;
449
+ let root_package = make_package ( root_config. to_owned ( ) , project_root, false , true ) ;
450
+ map. insert ( root_package. name . to_string ( ) , root_package) ;
451
451
452
452
let mut registered_dependencies_set: AHashSet < String > = AHashSet :: new ( ) ;
453
453
let dependencies = flatten_dependencies ( read_dependencies (
@@ -460,10 +460,8 @@ fn read_packages(
460
460
) ) ;
461
461
dependencies. iter ( ) . for_each ( |d| {
462
462
if !map. contains_key ( & d. name ) {
463
- map. insert (
464
- d. name . to_owned ( ) ,
465
- make_package ( d. config . to_owned ( ) , & d. path , d. is_pinned , false ) ,
466
- ) ;
463
+ let package = make_package ( d. config . to_owned ( ) , & d. path , d. is_pinned , false ) ;
464
+ map. insert ( package. name . to_string ( ) , package) ;
467
465
}
468
466
} ) ;
469
467
@@ -581,12 +579,6 @@ pub fn make(
581
579
Ok ( result)
582
580
}
583
581
584
- pub fn get_package_name ( path : & str ) -> Result < String > {
585
- let config = read_config ( path) ?;
586
-
587
- Ok ( config. name )
588
- }
589
-
590
582
pub fn parse_packages ( build_state : & mut BuildState ) {
591
583
build_state
592
584
. packages
0 commit comments