Gumaa
Gumaa
Explore posts from servers
DDeno
Created by Gumaa on 9/12/2023 in #help
Excluding certain directories when using "walk"
Hello, I'm writing a script that should crawl through a directory and search for a given text inside of these files. I'm having trouble understanding the documentation about walk options, specifically the skip option. It says:
skip: RegExp[] = undefined

List of regular expression patterns used to filter entries. If specified, entries matching the patterns specified by this option are excluded.
skip: RegExp[] = undefined

List of regular expression patterns used to filter entries. If specified, entries matching the patterns specified by this option are excluded.
But it is enigmatic - what exactly is being checked? The name of a file? Path of the file? Absolute path? Relative path? It does not say. If you are wondering I'm doing something like this:
const iter = walkSync(projectFolder, {
skip: [
/node_modules/,
/.git/,
/static/,
/lang/,
],
});

for (const entry of iter) {
if (entry.isFile) {
const content = Deno.readTextFileSync(entry.path);
checkContent(content);
}
}
const iter = walkSync(projectFolder, {
skip: [
/node_modules/,
/.git/,
/static/,
/lang/,
],
});

for (const entry of iter) {
if (entry.isFile) {
const content = Deno.readTextFileSync(entry.path);
checkContent(content);
}
}
So I just provided the name of a folder that I want to ignore. But I'm not sure if this is the correct approach or if this might ignore some extra files that I did not intent to ignore.
2 replies