1
0
This commit is contained in:
Zef Hemel
2023-11-21 12:05:17 +01:00
parent 79611a27e0
commit bdb4159f5b
+9 -1
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
}