@@ -334,14 +334,14 @@ fn read_dependencies(
334334 let ( config, canonical_path) =
335335 match read_dependency ( package_name, parent_path, project_root, & workspace_root) {
336336 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+ }
345345
346346 let parent_path_str = parent_path. to_string_lossy ( ) ;
347347 log:: error!(
@@ -359,9 +359,9 @@ fn read_dependencies(
359359 "We could not build package tree '{package_name}', at path '{parent_path_str}'. Error: {error}" ,
360360 ) ;
361361 std:: process:: exit ( 2 )
362- }
363- }
362+ }
364363 }
364+ }
365365 } ;
366366
367367 let is_pinned = parent_config
@@ -377,7 +377,7 @@ fn read_dependencies(
377377 project_root,
378378 workspace_root,
379379 show_progress,
380- build_dev_deps
380+ build_dev_deps,
381381 ) ;
382382
383383 Dependency {
@@ -416,7 +416,13 @@ pub fn read_package_name(package_dir: &Path) -> Result<String> {
416416 . ok_or_else ( || anyhow ! ( "No name field found in package.json" ) )
417417}
418418
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 {
420426 let source_folders = match config. sources . to_owned ( ) {
421427 Some ( config:: OneOrMore :: Single ( source) ) => get_source_dirs ( source, None ) ,
422428 Some ( config:: OneOrMore :: Multiple ( sources) ) => {
@@ -455,6 +461,11 @@ This inconsistency will cause issues with package resolution.\n",
455461 ) ;
456462 }
457463
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+
458469 Package {
459470 name : package_name,
460471 config : config. to_owned ( ) ,
@@ -469,7 +480,7 @@ This inconsistency will cause issues with package resolution.\n",
469480 . expect ( "Could not canonicalize" ) ,
470481 dirs : None ,
471482 is_pinned_dep,
472- is_local_dep : !package_path . components ( ) . any ( |c| c . as_os_str ( ) == "node_modules" ) ,
483+ is_local_dep,
473484 is_root,
474485 }
475486}
@@ -484,7 +495,7 @@ fn read_packages(
484495
485496 // Store all packages and completely deduplicate them
486497 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 ) ;
488499 map. insert ( root_package. name . to_string ( ) , root_package) ;
489500
490501 let mut registered_dependencies_set: AHashSet < String > = AHashSet :: new ( ) ;
@@ -499,7 +510,7 @@ fn read_packages(
499510 ) ) ;
500511 dependencies. iter ( ) . for_each ( |d| {
501512 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 ) ;
503514 map. insert ( d. name . to_string ( ) , package) ;
504515 }
505516 } ) ;
0 commit comments