Skip to content

Commit bc488f9

Browse files
avoid globbing non-dynamic paths
1 parent 8913dff commit bc488f9

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/walker.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable require-atomic-updates */
22

33
import assert from 'assert';
4+
import { existsSync } from 'fs';
45
import fs from 'fs/promises';
56
import path from 'path';
67
import { builtinModules } from 'module';
@@ -194,7 +195,22 @@ function upon(p: string, base: string) {
194195
}
195196

196197
function collect(ps: string[]) {
197-
return globSync(ps, { absolute: true, dot: true });
198+
const patterns: string[] = [];
199+
const paths: string[] = [];
200+
201+
for (const pattern of ps) {
202+
if (isDynamicPattern(pattern)) {
203+
patterns.push(pattern);
204+
} else if (existsSync(pattern)) {
205+
paths.push(pattern);
206+
}
207+
}
208+
209+
if (globPatterns.length !== 0) {
210+
return [...paths, ...globSync(patterns, { absolute: true, dot: true })];
211+
}
212+
213+
return paths;
198214
}
199215

200216
function expandFiles(efs: string | string[], base: string) {

0 commit comments

Comments
 (0)