1
1
use super :: build_types:: * ;
2
2
use super :: namespaces;
3
3
use super :: packages;
4
- use crate :: build:: packages:: DependencySymLink :: { NoSymlink , Symlink } ;
5
4
use crate :: config;
6
5
use crate :: helpers;
7
6
use crate :: helpers:: StrippedVerbatimPath ;
@@ -40,22 +39,13 @@ impl Namespace {
40
39
}
41
40
}
42
41
43
- #[ derive( Debug , Clone ) ]
44
- pub enum DependencySymLink {
45
- NoSymlink ,
46
- Symlink ( PathBuf ) ,
47
- }
48
-
49
42
#[ derive( Debug , Clone ) ]
50
43
struct Dependency {
51
44
name : String ,
52
45
config : config:: Config ,
53
46
path : PathBuf ,
54
47
is_pinned : bool ,
55
48
dependencies : Vec < Dependency > ,
56
- // Track if the original dependency path actually a symbolic link.
57
- // We need to know this to later assert if a package is local or not.
58
- sym_link : DependencySymLink ,
59
49
}
60
50
61
51
#[ derive( Debug , Clone ) ]
@@ -264,7 +254,7 @@ pub fn read_dependency(
264
254
parent_path : & Path ,
265
255
project_root : & Path ,
266
256
workspace_root : & Option < PathBuf > ,
267
- ) -> Result < ( PathBuf , DependencySymLink ) , String > {
257
+ ) -> Result < PathBuf , String > {
268
258
let path_from_parent = PathBuf :: from ( helpers:: package_path ( parent_path, package_name) ) ;
269
259
let path_from_project_root = PathBuf :: from ( helpers:: package_path ( project_root, package_name) ) ;
270
260
let maybe_path_from_workspace_root = workspace_root
@@ -287,17 +277,6 @@ pub fn read_dependency(
287
277
) ) ,
288
278
} ?;
289
279
290
- // There could be a symbolic link because the package.json has:
291
- // "dependencies": {
292
- // "my-package": "link:my-package",
293
- // }
294
- // In this case, there will be a link from node_modules/my-package to a local path.
295
- let symlink = match fs:: symlink_metadata ( & path) . map ( |m| m. file_type ( ) . is_symlink ( ) ) {
296
- Err ( _) => NoSymlink ,
297
- Ok ( false ) => NoSymlink ,
298
- Ok ( true ) => Symlink ( path. clone ( ) ) ,
299
- } ;
300
-
301
280
let canonical_path = match path
302
281
. canonicalize ( )
303
282
. map ( StrippedVerbatimPath :: to_stripped_verbatim_path)
@@ -311,7 +290,7 @@ pub fn read_dependency(
311
290
) ) ,
312
291
} ?;
313
292
314
- Ok ( ( canonical_path, symlink ) )
293
+ Ok ( canonical_path)
315
294
}
316
295
317
296
/// # Make Package
@@ -352,7 +331,7 @@ fn read_dependencies(
352
331
// Read all config files in parallel instead of blocking
353
332
. par_iter ( )
354
333
. map ( |package_name| {
355
- let ( config, canonical_path, sym_link ) =
334
+ let ( config, canonical_path) =
356
335
match read_dependency ( package_name, parent_path, project_root, & workspace_root) {
357
336
Err ( error) => {
358
337
if show_progress {
@@ -371,9 +350,9 @@ fn read_dependencies(
371
350
372
351
std:: process:: exit ( 2 )
373
352
}
374
- Ok ( ( canonical_path, sym_link ) ) => {
353
+ Ok ( canonical_path) => {
375
354
match read_config ( & canonical_path) {
376
- Ok ( config) => ( config, canonical_path, sym_link ) ,
355
+ Ok ( config) => ( config, canonical_path) ,
377
356
Err ( error) => {
378
357
let parent_path_str = parent_path. to_string_lossy ( ) ;
379
358
log:: error!(
@@ -407,7 +386,6 @@ fn read_dependencies(
407
386
path : canonical_path,
408
387
is_pinned,
409
388
dependencies,
410
- sym_link
411
389
}
412
390
} )
413
391
. collect ( )
@@ -438,13 +416,7 @@ pub fn read_package_name(package_dir: &Path) -> Result<String> {
438
416
. ok_or_else ( || anyhow ! ( "No name field found in package.json" ) )
439
417
}
440
418
441
- fn make_package (
442
- config : config:: Config ,
443
- package_path : & Path ,
444
- is_pinned_dep : bool ,
445
- is_root : bool ,
446
- is_local_dep : bool ,
447
- ) -> Package {
419
+ fn make_package ( config : config:: Config , package_path : & Path , is_pinned_dep : bool , is_root : bool ) -> Package {
448
420
let source_folders = match config. sources . to_owned ( ) {
449
421
Some ( config:: OneOrMore :: Single ( source) ) => get_source_dirs ( source, None ) ,
450
422
Some ( config:: OneOrMore :: Multiple ( sources) ) => {
@@ -497,7 +469,7 @@ This inconsistency will cause issues with package resolution.\n",
497
469
. expect ( "Could not canonicalize" ) ,
498
470
dirs : None ,
499
471
is_pinned_dep,
500
- is_local_dep,
472
+ is_local_dep : !package_path . components ( ) . any ( |c| c . as_os_str ( ) == "node_modules" ) ,
501
473
is_root,
502
474
}
503
475
}
@@ -512,7 +484,7 @@ fn read_packages(
512
484
513
485
// Store all packages and completely deduplicate them
514
486
let mut map: AHashMap < String , Package > = AHashMap :: new ( ) ;
515
- let root_package = make_package ( root_config. to_owned ( ) , project_root, false , true , true ) ;
487
+ let root_package = make_package ( root_config. to_owned ( ) , project_root, false , true ) ;
516
488
map. insert ( root_package. name . to_string ( ) , root_package) ;
517
489
518
490
let mut registered_dependencies_set: AHashSet < String > = AHashSet :: new ( ) ;
@@ -527,13 +499,7 @@ fn read_packages(
527
499
) ) ;
528
500
dependencies. iter ( ) . for_each ( |d| {
529
501
if !map. contains_key ( & d. name ) {
530
- let is_local_dep = match & d. sym_link {
531
- NoSymlink => !d. path . components ( ) . any ( |c| c. as_os_str ( ) == "node_modules" ) ,
532
- Symlink ( original_path) => !original_path
533
- . components ( )
534
- . any ( |c| c. as_os_str ( ) == "node_modules" ) ,
535
- } ;
536
- let package = make_package ( d. config . to_owned ( ) , & d. path , d. is_pinned , false , is_local_dep) ;
502
+ let package = make_package ( d. config . to_owned ( ) , & d. path , d. is_pinned , false ) ;
537
503
map. insert ( d. name . to_string ( ) , package) ;
538
504
}
539
505
} ) ;
0 commit comments