Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

Commit e0b3cbd

Browse files
committed
fix: exclude paths under node_modules from exact enumeration
Previously, the `exact` enumeration method would include any paths under inside `node_modules` directories. This change filters those files out.
1 parent 0396f34 commit e0b3cbd

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/exact.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ use rayon::prelude::*;
1212
use typescript_tools::{configuration_file::ConfigurationFile, monorepo_manifest};
1313

1414
use crate::{
15-
path::{self, is_monorepo_file, remove_relative_path_prefix_from_absolute_path},
15+
path::{
16+
self, is_child_of_node_modules, is_monorepo_file,
17+
remove_relative_path_prefix_from_absolute_path,
18+
},
1619
typescript_package::{
1720
FromTypescriptConfigFileError, PackageInMonorepoRootError, PackageManifest,
1821
PackageManifestFile, TypescriptConfigFile, TypescriptPackage,
@@ -136,6 +139,7 @@ fn tsconfig_includes_exact(
136139
.filter(|s| !s.is_empty())
137140
.map(PathBuf::from)
138141
.filter(|path| is_monorepo_file(&monorepo_root, path))
142+
.filter(|path| !is_child_of_node_modules(path))
139143
.map(|source_file| {
140144
remove_relative_path_prefix_from_absolute_path(&monorepo_root, &source_file)
141145
})

src/path.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,12 @@ pub(crate) fn is_monorepo_file(monorepo_root: &Path, file: &Path) -> bool {
101101
}
102102
false
103103
}
104+
105+
pub(crate) fn is_child_of_node_modules(file: &Path) -> bool {
106+
for ancestor in file.ancestors() {
107+
if ancestor.ends_with("node_modules") {
108+
return true;
109+
}
110+
}
111+
false
112+
}

0 commit comments

Comments
 (0)