pull/570/head
Zef Hemel 2023-11-21 12:05:17 +01:00
parent 79611a27e0
commit bdb4159f5b
1 changed files with 9 additions and 1 deletions

View File

@ -78,7 +78,11 @@ export default function fileSystemSyscalls(root = "/"): SysCallMapping {
const file of walk(dirPath, {
includeDirs: false,
// Exclude hidden files
skip: [/^.*\/\..+$/],
skip: [
// Dynamically builds a regexp that matches hidden directories INSIDE the rootPath
// (but if the rootPath is hidden, it stil lists files inside of it, fixing #130 and #518)
new RegExp(`^${escapeRegExp(root)}.*\\/\\..+$`),
],
maxDepth: recursive ? Infinity : 1,
})
) {
@ -97,3 +101,7 @@ export default function fileSystemSyscalls(root = "/"): SysCallMapping {
},
};
}
function escapeRegExp(string: string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
}