@@ -331,14 +331,14 @@ fn read_dependencies(
331
331
let ( config, canonical_path) =
332
332
match read_dependency ( package_name, parent_path, project_root, workspace_root) {
333
333
Err ( error) => {
334
- if show_progress {
335
- println ! (
336
- "{} {} Error building package tree. {}" ,
337
- style( "[1/2]" ) . bold( ) . dim( ) ,
338
- CROSS ,
339
- error
340
- ) ;
341
- }
334
+ if show_progress {
335
+ println ! (
336
+ "{} {} Error building package tree. {}" ,
337
+ style( "[1/2]" ) . bold( ) . dim( ) ,
338
+ CROSS ,
339
+ error
340
+ ) ;
341
+ }
342
342
343
343
let parent_path_str = parent_path. to_string_lossy ( ) ;
344
344
log:: error!(
@@ -356,9 +356,9 @@ fn read_dependencies(
356
356
"We could not build package tree '{package_name}', at path '{parent_path_str}'. Error: {error}" ,
357
357
) ;
358
358
std:: process:: exit ( 2 )
359
- }
360
- }
359
+ }
361
360
}
361
+ }
362
362
} ;
363
363
364
364
let is_pinned = parent_config
@@ -374,7 +374,7 @@ fn read_dependencies(
374
374
project_root,
375
375
workspace_root,
376
376
show_progress,
377
- build_dev_deps
377
+ build_dev_deps,
378
378
) ;
379
379
380
380
Dependency {
@@ -413,7 +413,13 @@ pub fn read_package_name(package_dir: &Path) -> Result<String> {
413
413
. ok_or_else ( || anyhow ! ( "No name field found in package.json" ) )
414
414
}
415
415
416
- fn make_package ( config : config:: Config , package_path : & Path , is_pinned_dep : bool , is_root : bool ) -> Package {
416
+ fn make_package (
417
+ config : config:: Config ,
418
+ package_path : & Path ,
419
+ is_pinned_dep : bool ,
420
+ is_root : bool ,
421
+ project_root : & Path ,
422
+ ) -> Package {
417
423
let source_folders = match config. sources . to_owned ( ) {
418
424
Some ( config:: OneOrMore :: Single ( source) ) => get_source_dirs ( source, None ) ,
419
425
Some ( config:: OneOrMore :: Multiple ( sources) ) => {
@@ -452,6 +458,11 @@ This inconsistency will cause issues with package resolution.\n",
452
458
) ;
453
459
}
454
460
461
+ let is_local_dep = {
462
+ package_path. starts_with ( project_root)
463
+ && !package_path. components ( ) . any ( |c| c. as_os_str ( ) == "node_modules" )
464
+ } ;
465
+
455
466
Package {
456
467
name : package_name,
457
468
config : config. to_owned ( ) ,
@@ -466,7 +477,7 @@ This inconsistency will cause issues with package resolution.\n",
466
477
. expect ( "Could not canonicalize" ) ,
467
478
dirs : None ,
468
479
is_pinned_dep,
469
- is_local_dep : !package_path . components ( ) . any ( |c| c . as_os_str ( ) == "node_modules" ) ,
480
+ is_local_dep,
470
481
is_root,
471
482
}
472
483
}
@@ -481,7 +492,7 @@ fn read_packages(
481
492
482
493
// Store all packages and completely deduplicate them
483
494
let mut map: AHashMap < String , Package > = AHashMap :: new ( ) ;
484
- let root_package = make_package ( root_config. to_owned ( ) , project_root, false , true ) ;
495
+ let root_package = make_package ( root_config. to_owned ( ) , project_root, false , true , project_root ) ;
485
496
map. insert ( root_package. name . to_string ( ) , root_package) ;
486
497
487
498
let mut registered_dependencies_set: AHashSet < String > = AHashSet :: new ( ) ;
@@ -496,7 +507,7 @@ fn read_packages(
496
507
) ) ;
497
508
dependencies. iter ( ) . for_each ( |d| {
498
509
if !map. contains_key ( & d. name ) {
499
- let package = make_package ( d. config . to_owned ( ) , & d. path , d. is_pinned , false ) ;
510
+ let package = make_package ( d. config . to_owned ( ) , & d. path , d. is_pinned , false , project_root ) ;
500
511
map. insert ( d. name . to_string ( ) , package) ;
501
512
}
502
513
} ) ;
0 commit comments