Skip to content

Commit 4740ff2

Browse files
committed
Add excluded directories
1 parent 9e0bdcf commit 4740ff2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

server/src/utils/helpers.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ export function walk(dirOrUri: string, pattern?: RegExp, files: Map<string, stri
5353
const logger = Services.logger;
5454
logger.debug(`Walking ${dirOrUri}`);
5555

56+
const excludedDirectories = new Set([
57+
'.git',
58+
'.svn',
59+
'node_modules',
60+
'.vscode',
61+
'.vs'
62+
]);
63+
5664
// Walk the contents of the directory.
5765
const dir = dirOrUri.toFilePath();
5866
for (const name of fs.readdirSync(dir)) {
@@ -63,6 +71,10 @@ export function walk(dirOrUri: string, pattern?: RegExp, files: Map<string, stri
6371
try { pIsDirectory = fs.statSync(p).isDirectory(); }
6472
catch (e) { logger.warn(`The OS threw an exception checking whether ${p} is a directory.`, 0, e); }
6573
if (pIsDirectory) {
74+
if (excludedDirectories.has(name) || name.startsWith('.')) {
75+
logger.debug(`Skipping excluded directory: ${p}`, 1);
76+
continue;
77+
}
6678
// Recursive call for directories.
6779
walk(p, pattern, files);
6880
} else if (pattern?.test(name) ?? true) {

0 commit comments

Comments
 (0)