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