Skip to content

Commit ec0266f

Browse files
committed
fix: only skip absolute system /dev paths
1 parent 59dfd3f commit ec0266f

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

index.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ class BunKill {
682682
}
683683

684684
private shouldSkipDirectory(dirPath: string): boolean {
685-
const skipPatterns = [
685+
const absoluteSkipRoots = [
686686
"/System",
687687
"/Library/Application Support",
688688
"/Library/Frameworks",
@@ -705,6 +705,9 @@ class BunKill {
705705
"/opt/homebrew",
706706
"/usr/local/bin",
707707
"/usr/local/sbin",
708+
];
709+
710+
const nameSkipPatterns = [
708711
".photolibrary",
709712
".photoslibrary",
710713
".photoboothlibrary",
@@ -743,9 +746,19 @@ class BunKill {
743746
return false;
744747
}
745748

746-
return skipPatterns.some((pattern) =>
747-
dirPath.includes(pattern) ||
748-
dirPath.toLowerCase().includes(pattern.toLowerCase())
749+
const normalizedPath = dirPath.toLowerCase();
750+
const isAbsoluteSkip = absoluteSkipRoots.some((root) => {
751+
const normalizedRoot = root.toLowerCase();
752+
return normalizedPath === normalizedRoot ||
753+
normalizedPath.startsWith(`${normalizedRoot}/`);
754+
});
755+
756+
if (isAbsoluteSkip) {
757+
return true;
758+
}
759+
760+
return nameSkipPatterns.some((pattern) =>
761+
normalizedPath.includes(pattern.toLowerCase())
749762
);
750763
}
751764

0 commit comments

Comments
 (0)