view-ignored 0.10.1 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -66
- package/out/browser.d.ts +1 -0
- package/out/browser.js +1 -0
- package/out/browser_scan.d.ts +1 -3
- package/out/browser_scan.js +11 -46
- package/out/browser_stream.d.ts +6 -1
- package/out/browser_stream.js +6 -1
- package/out/index.d.ts +1 -0
- package/out/index.js +1 -0
- package/out/patterns/extractor.d.ts +7 -7
- package/out/patterns/gitignore.d.ts +2 -2
- package/out/patterns/gitignore.js +14 -6
- package/out/patterns/ignores.d.ts +17 -8
- package/out/patterns/index.d.ts +1 -0
- package/out/patterns/index.js +1 -0
- package/out/patterns/init.d.ts +2 -2
- package/out/patterns/initState.d.ts +0 -7
- package/out/patterns/jsrjson.d.ts +2 -3
- package/out/patterns/jsrjson.js +25 -38
- package/out/patterns/matcherContext.d.ts +12 -9
- package/out/patterns/matcherContextPatch.js +153 -73
- package/out/patterns/matcherStream.d.ts +19 -59
- package/out/patterns/matcherStream.js +75 -25
- package/out/patterns/matcherStreamTypes.d.ts +65 -0
- package/out/patterns/matcherStreamTypes.js +1 -0
- package/out/patterns/packagejson.d.ts +2 -2
- package/out/patterns/packagejson.js +11 -14
- package/out/patterns/patternCompile.js +35 -37
- package/out/patterns/patternList.d.ts +6 -2
- package/out/patterns/patternList.js +8 -3
- package/out/patterns/resolveSources.d.ts +22 -5
- package/out/patterns/resolveSources.js +153 -97
- package/out/patterns/resource.d.ts +16 -0
- package/out/patterns/resource.js +1 -0
- package/out/patterns/rule.d.ts +59 -11
- package/out/patterns/rule.js +101 -64
- package/out/patterns/source.d.ts +9 -17
- package/out/scan.d.ts +11 -3
- package/out/scan.js +16 -4
- package/out/scanCb.d.ts +16 -0
- package/out/scanCb.js +73 -0
- package/out/scanParallel.d.ts +18 -0
- package/out/scanParallel.js +146 -0
- package/out/stream.d.ts +6 -1
- package/out/stream.js +7 -2
- package/out/targets/bun.js +43 -36
- package/out/targets/deno.js +25 -23
- package/out/targets/git.js +3 -3
- package/out/targets/jsr.js +25 -23
- package/out/targets/jsrManifest.d.ts +8 -7
- package/out/targets/jsrManifest.js +40 -9
- package/out/targets/npm.js +30 -23
- package/out/targets/npmManifest.d.ts +18 -46
- package/out/targets/npmManifest.js +96 -23
- package/out/targets/target.d.ts +8 -16
- package/out/targets/vsce.js +20 -27
- package/out/targets/vsceManifest.d.ts +7 -0
- package/out/targets/vsceManifest.js +18 -0
- package/out/targets/yarn.js +48 -39
- package/out/targets/yarnClassic.js +20 -18
- package/out/types.d.ts +8 -7
- package/out/unixify.d.ts +1 -1
- package/out/unixify.js +40 -21
- package/out/walk.d.ts +42 -4
- package/out/walk.js +146 -92
- package/package.json +42 -27
- package/out/getDepth.d.ts +0 -4
- package/out/getDepth.js +0 -21
- package/out/opendir.d.ts +0 -3
- package/out/opendir.js +0 -28
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { walkIncludes } from "../walk.js";
|
|
1
|
+
import { scanParallel } from "../scanParallel.js";
|
|
2
|
+
import { unixify } from "../unixify.js";
|
|
3
|
+
import { walkPatchResult, walkPatchTotal, propagateTotals } from "../walk.js";
|
|
5
4
|
/**
|
|
6
5
|
* Event emitter.
|
|
7
|
-
* @
|
|
6
|
+
* @augments EventTarget
|
|
8
7
|
*
|
|
9
8
|
* @since 0.6.0
|
|
10
9
|
*/
|
|
11
|
-
export class MatcherStream extends
|
|
10
|
+
export class MatcherStream extends EventTarget {
|
|
12
11
|
#timeout;
|
|
13
12
|
#options;
|
|
14
13
|
constructor(options) {
|
|
15
|
-
super(
|
|
14
|
+
super();
|
|
16
15
|
this.#options = options;
|
|
17
16
|
if (!options.noTimeout) {
|
|
18
17
|
this.#timeout = setTimeout(() => {
|
|
@@ -20,27 +19,53 @@ export class MatcherStream extends EventEmitter {
|
|
|
20
19
|
}, 5e3);
|
|
21
20
|
}
|
|
22
21
|
}
|
|
22
|
+
addEventListener(type, callback, options) {
|
|
23
|
+
super.addEventListener(type, callback, options);
|
|
24
|
+
}
|
|
25
|
+
removeEventListener(type, callback, options) {
|
|
26
|
+
super.removeEventListener(type, callback, options);
|
|
27
|
+
}
|
|
28
|
+
dispatchEvent(event) {
|
|
29
|
+
return super.dispatchEvent(event);
|
|
30
|
+
}
|
|
23
31
|
/**
|
|
24
32
|
* Resolves when everything is scanned.
|
|
25
33
|
*
|
|
26
34
|
* @since 0.8.0
|
|
27
35
|
*/
|
|
28
|
-
|
|
36
|
+
start() {
|
|
37
|
+
let resolve;
|
|
38
|
+
let reject;
|
|
39
|
+
const promise = new Promise((res, rej) => {
|
|
40
|
+
resolve = res;
|
|
41
|
+
reject = rej;
|
|
42
|
+
});
|
|
43
|
+
this.startCb((err) => {
|
|
44
|
+
if (err) {
|
|
45
|
+
reject(err);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
resolve();
|
|
49
|
+
});
|
|
50
|
+
return promise;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Resolves when everything is scanned. (Callback version)
|
|
54
|
+
*
|
|
55
|
+
* @since 0.11.0
|
|
56
|
+
*/
|
|
57
|
+
startCb(cb) {
|
|
29
58
|
clearTimeout(this.#timeout);
|
|
30
59
|
const { target, cwd, within = ".", invert = false, depth: maxDepth = Infinity, signal = null, fastDepth = false, fastInternal = false, fs, } = this.#options;
|
|
31
60
|
const ctx = {
|
|
32
|
-
paths: new Map(),
|
|
33
61
|
external: new Map(),
|
|
34
62
|
failed: [],
|
|
35
|
-
|
|
36
|
-
totalFiles: 0,
|
|
37
|
-
totalMatchedFiles: 0,
|
|
38
|
-
totalDirs: 0,
|
|
63
|
+
paths: new Map(),
|
|
64
|
+
total: new Map([[".", { totalDirs: 0, totalFiles: 0, totalMatchedFiles: 0 }]]),
|
|
39
65
|
};
|
|
40
66
|
const normalCwd = unixify(cwd);
|
|
41
67
|
const scanOptions = {
|
|
42
68
|
cwd: normalCwd,
|
|
43
|
-
within,
|
|
44
69
|
depth: maxDepth,
|
|
45
70
|
fastDepth,
|
|
46
71
|
fastInternal,
|
|
@@ -48,19 +73,44 @@ export class MatcherStream extends EventEmitter {
|
|
|
48
73
|
invert,
|
|
49
74
|
signal,
|
|
50
75
|
target,
|
|
76
|
+
within,
|
|
51
77
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
78
|
+
const startScan = () => {
|
|
79
|
+
scanParallel({
|
|
80
|
+
external: ctx.external,
|
|
81
|
+
failed: ctx.failed,
|
|
82
|
+
onResult: (result) => {
|
|
83
|
+
if ("dir" in result) {
|
|
84
|
+
walkPatchTotal(ctx, scanOptions.depth, result);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
walkPatchResult(ctx, result);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
61
90
|
scanOptions,
|
|
91
|
+
stream: this,
|
|
92
|
+
within,
|
|
93
|
+
}, (err) => {
|
|
94
|
+
if (err) {
|
|
95
|
+
cb(err, null);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
propagateTotals(ctx.total);
|
|
99
|
+
cb(null, ctx);
|
|
100
|
+
this.dispatchEvent(new CustomEvent("end", { detail: ctx }));
|
|
62
101
|
});
|
|
63
|
-
}
|
|
64
|
-
|
|
102
|
+
};
|
|
103
|
+
if (target.init) {
|
|
104
|
+
target.init({ cwd: normalCwd, fs, signal, target }, (err) => {
|
|
105
|
+
if (err) {
|
|
106
|
+
cb(err, null);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
startScan();
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
startScan();
|
|
114
|
+
}
|
|
65
115
|
}
|
|
66
116
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Dirent } from "node:fs";
|
|
2
|
+
import type { MatcherContext } from "./matcherContext.js";
|
|
3
|
+
import type { RuleMatch } from "./rule.js";
|
|
4
|
+
/**
|
|
5
|
+
* Post-scan entry information.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.6.0
|
|
8
|
+
*/
|
|
9
|
+
export type EntryInfo = {
|
|
10
|
+
/**
|
|
11
|
+
* The relative path of the entry.
|
|
12
|
+
*
|
|
13
|
+
* @since 0.6.0
|
|
14
|
+
*/
|
|
15
|
+
path: string;
|
|
16
|
+
/**
|
|
17
|
+
* The directory entry.
|
|
18
|
+
*
|
|
19
|
+
* @since 0.6.0
|
|
20
|
+
*/
|
|
21
|
+
dirent: Dirent;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the entry was ignored.
|
|
24
|
+
*
|
|
25
|
+
* @since 0.6.0
|
|
26
|
+
*/
|
|
27
|
+
match: RuleMatch;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* @see {@link MatcherStream} uses it for the "dirent" event.
|
|
31
|
+
*
|
|
32
|
+
* @since 0.6.0
|
|
33
|
+
*/
|
|
34
|
+
export type EntryListener = (info: EntryInfo) => void;
|
|
35
|
+
/**
|
|
36
|
+
* @see {@link MatcherStream} uses it for the "end" event.
|
|
37
|
+
*
|
|
38
|
+
* @since 0.6.0
|
|
39
|
+
*/
|
|
40
|
+
export type EndListener = (ctx: MatcherContext) => void;
|
|
41
|
+
/**
|
|
42
|
+
* @see {@link MatcherStream} uses it for its event map.
|
|
43
|
+
*
|
|
44
|
+
* @since 0.6.0
|
|
45
|
+
*/
|
|
46
|
+
export type EventMap = {
|
|
47
|
+
dirent: CustomEvent<EntryInfo>;
|
|
48
|
+
end: CustomEvent<MatcherContext>;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @see {@link MatcherStream} uses it for its event map.
|
|
52
|
+
*
|
|
53
|
+
* @since 0.11.0
|
|
54
|
+
*/
|
|
55
|
+
export interface EventListener<K extends keyof EventMap> {
|
|
56
|
+
(evt: EventMap[K]): void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @see {@link MatcherStream} uses it for its event map.
|
|
60
|
+
*
|
|
61
|
+
* @since 0.11.0
|
|
62
|
+
*/
|
|
63
|
+
export interface EventListenerObject<K extends keyof EventMap> {
|
|
64
|
+
handleEvent(object: EventMap[K]): void;
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,7 +6,7 @@ import { type Source } from "./source.js";
|
|
|
6
6
|
*
|
|
7
7
|
* @since 0.6.0
|
|
8
8
|
*/
|
|
9
|
-
export declare function extractPackageJson(source: Source, content: Buffer): void |
|
|
9
|
+
export declare function extractPackageJson(source: Source, content: Buffer): void | null | Error;
|
|
10
10
|
/**
|
|
11
11
|
* Extracts and compiles patterns from the file.
|
|
12
12
|
*
|
|
@@ -14,4 +14,4 @@ export declare function extractPackageJson(source: Source, content: Buffer): voi
|
|
|
14
14
|
*
|
|
15
15
|
* @since 0.8.0
|
|
16
16
|
*/
|
|
17
|
-
export declare function extractPackageJsonNocase(source: Source, content: Buffer): void |
|
|
17
|
+
export declare function extractPackageJsonNocase(source: Source, content: Buffer): void | null | Error;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type } from "arktype";
|
|
2
1
|
import { npmManifestParse } from "../targets/npmManifest.js";
|
|
3
2
|
import { ruleCompile } from "./resolveSources.js";
|
|
4
3
|
import { resolveNegatable } from "./source.js";
|
|
@@ -12,12 +11,10 @@ import { resolveNegatable } from "./source.js";
|
|
|
12
11
|
export function extractPackageJson(source, content) {
|
|
13
12
|
const result = extract(source, content);
|
|
14
13
|
if (result === undefined) {
|
|
15
|
-
for (const element of source.
|
|
14
|
+
for (const element of source.rules) {
|
|
16
15
|
ruleCompile(element);
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
|
-
if (result === "error")
|
|
20
|
-
return;
|
|
21
18
|
return result;
|
|
22
19
|
}
|
|
23
20
|
/**
|
|
@@ -30,29 +27,29 @@ export function extractPackageJson(source, content) {
|
|
|
30
27
|
export function extractPackageJsonNocase(source, content) {
|
|
31
28
|
const result = extract(source, content);
|
|
32
29
|
if (result === undefined) {
|
|
33
|
-
for (const element of source.
|
|
30
|
+
for (const element of source.rules) {
|
|
34
31
|
ruleCompile(element, { nocase: true });
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
if (result === "error")
|
|
38
|
-
return;
|
|
39
34
|
return result;
|
|
40
35
|
}
|
|
41
36
|
function extract(source, content) {
|
|
42
37
|
source.inverted = true;
|
|
43
38
|
const include = { compiled: null, excludes: false, pattern: [] };
|
|
44
39
|
const exclude = { compiled: null, excludes: true, pattern: [] };
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return "error";
|
|
40
|
+
let dist;
|
|
41
|
+
try {
|
|
42
|
+
dist = npmManifestParse(content.toString());
|
|
49
43
|
}
|
|
50
|
-
|
|
51
|
-
return "
|
|
44
|
+
catch (err) {
|
|
45
|
+
return new Error("Invalid '" + source.path + "': Expected '}'", { cause: err });
|
|
46
|
+
}
|
|
47
|
+
if (!dist?.files || !Array.isArray(dist.files)) {
|
|
48
|
+
return null;
|
|
52
49
|
}
|
|
53
50
|
for (const pattern of dist.files) {
|
|
54
51
|
resolveNegatable(pattern, true, include, exclude);
|
|
55
52
|
}
|
|
56
|
-
source.
|
|
53
|
+
source.rules.push(include, exclude);
|
|
57
54
|
}
|
|
58
55
|
extractPackageJson;
|
|
@@ -7,56 +7,54 @@ import glob from "micromatch";
|
|
|
7
7
|
* @since 0.8.0
|
|
8
8
|
*/
|
|
9
9
|
export function patternCompile(pattern, context = [], options) {
|
|
10
|
-
const
|
|
11
|
-
const isRoot = pattern.startsWith("/");
|
|
10
|
+
const isRoot = pattern.charCodeAt(0) === 47; // '/'
|
|
12
11
|
const nocase = !!options?.nocase;
|
|
13
12
|
let cleaned = pattern;
|
|
14
|
-
if (cleaned.
|
|
13
|
+
if (cleaned.charCodeAt(cleaned.length - 1) === 47)
|
|
15
14
|
cleaned = cleaned.slice(0, -1);
|
|
16
15
|
if (isRoot)
|
|
17
16
|
cleaned = cleaned.slice(1);
|
|
18
17
|
const lowerCleaned = nocase ? cleaned.toLowerCase() : cleaned;
|
|
19
|
-
const prefix = lowerCleaned + "/";
|
|
20
|
-
const hasGlob = cleaned.includes("*");
|
|
21
18
|
const matchBase = !isRoot && !cleaned.includes("/");
|
|
22
19
|
const matcherOpts = {
|
|
23
20
|
dot: true,
|
|
24
|
-
|
|
25
|
-
nocomment: true,
|
|
21
|
+
matchBase,
|
|
26
22
|
nobrace: true,
|
|
27
23
|
nocase,
|
|
28
|
-
|
|
29
|
-
optimizationLevel: 2,
|
|
24
|
+
nonegate: true,
|
|
30
25
|
};
|
|
26
|
+
const isMatch = glob.matcher(lowerCleaned, { ...matcherOpts, nocase: false });
|
|
31
27
|
const re = {
|
|
32
|
-
test(str)
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
test: (str, matchCtx) => test(str, matchCtx, isMatch, lowerCleaned, isRoot, nocase, matchBase),
|
|
29
|
+
};
|
|
30
|
+
const cache = { pattern, patternContext: context, re };
|
|
31
|
+
return cache;
|
|
32
|
+
}
|
|
33
|
+
function test(str, matchCtx, isMatch, cleaned, isRoot, nocase, matchBase) {
|
|
34
|
+
const normStr = nocase ? (matchCtx.lower ?? (matchCtx.lower = str.toLowerCase())) : str;
|
|
35
|
+
if (normStr === cleaned || normStr.startsWith(cleaned + "/")) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
if (matchBase) {
|
|
39
|
+
const len = cleaned.length;
|
|
40
|
+
let pos = normStr.indexOf(cleaned);
|
|
41
|
+
while (pos !== -1) {
|
|
42
|
+
if ((pos === 0 || normStr.charCodeAt(pos - 1) === 47) &&
|
|
43
|
+
(pos + len === normStr.length || normStr.charCodeAt(pos + len) === 47)) {
|
|
35
44
|
return true;
|
|
36
45
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
while (lastSlash !== -1) {
|
|
52
|
-
const parent = str.substring(0, lastSlash);
|
|
53
|
-
if (glob.isMatch(parent, cleaned, matcherOpts))
|
|
54
|
-
return true;
|
|
55
|
-
lastSlash = str.lastIndexOf("/", lastSlash - 1);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
return { re, pattern: original, patternContext: context };
|
|
46
|
+
pos = normStr.indexOf(cleaned, pos + 1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (isMatch(normStr))
|
|
50
|
+
return true;
|
|
51
|
+
if (!isRoot) {
|
|
52
|
+
let lastSlash = normStr.lastIndexOf("/");
|
|
53
|
+
while (lastSlash !== -1) {
|
|
54
|
+
if (isMatch(normStr.slice(0, lastSlash)))
|
|
55
|
+
return true;
|
|
56
|
+
lastSlash = normStr.lastIndexOf("/", lastSlash - 1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
62
60
|
}
|
|
@@ -14,7 +14,9 @@ export type PatternCache = {
|
|
|
14
14
|
* @since 0.6.0
|
|
15
15
|
*/
|
|
16
16
|
re: {
|
|
17
|
-
test(string: string
|
|
17
|
+
test(string: string, matchCtx: {
|
|
18
|
+
lower?: string;
|
|
19
|
+
}): boolean;
|
|
18
20
|
};
|
|
19
21
|
/**
|
|
20
22
|
* The original pattern string this cache was compiled from.
|
|
@@ -34,7 +36,9 @@ export type PatternCache = {
|
|
|
34
36
|
*
|
|
35
37
|
* @since 0.6.0
|
|
36
38
|
*/
|
|
37
|
-
export declare function patternCacheTest(cache: PatternCache, path: string
|
|
39
|
+
export declare function patternCacheTest(cache: PatternCache, path: string, matchCtx?: {
|
|
40
|
+
lower?: string;
|
|
41
|
+
}): boolean;
|
|
38
42
|
/**
|
|
39
43
|
* Represents a list of positive glob patterns.
|
|
40
44
|
*
|
|
@@ -4,8 +4,8 @@ import { patternCompile } from "./patternCompile.js";
|
|
|
4
4
|
*
|
|
5
5
|
* @since 0.6.0
|
|
6
6
|
*/
|
|
7
|
-
export function patternCacheTest(cache, path) {
|
|
8
|
-
return cache.re.test(path);
|
|
7
|
+
export function patternCacheTest(cache, path, matchCtx = {}) {
|
|
8
|
+
return cache.re.test(path, matchCtx);
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Compiles the {@link PatternList}.
|
|
@@ -16,5 +16,10 @@ export function patternCacheTest(cache, path) {
|
|
|
16
16
|
* @since 0.6.0
|
|
17
17
|
*/
|
|
18
18
|
export function patternListCompile(list, options) {
|
|
19
|
-
|
|
19
|
+
const len = list.length;
|
|
20
|
+
const res = Array.from({ length: len });
|
|
21
|
+
for (let i = 0; i < len; i++) {
|
|
22
|
+
res[i] = patternCompile(list[i], list, options);
|
|
23
|
+
}
|
|
24
|
+
return res;
|
|
20
25
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Dirent } from "node:fs";
|
|
2
2
|
import type { PatternCompileOptions } from "./patternCompile.js";
|
|
3
|
+
import type { Resource } from "./resource.js";
|
|
3
4
|
import type { Rule } from "./rule.js";
|
|
5
|
+
import { type PatternFinderOptions } from "./extractor.js";
|
|
4
6
|
/**
|
|
5
7
|
* Compiles the {@link Rule} (forced).
|
|
6
8
|
* Can be compiled at any time.
|
|
@@ -10,7 +12,7 @@ import type { Rule } from "./rule.js";
|
|
|
10
12
|
*
|
|
11
13
|
* @since 0.6.0
|
|
12
14
|
*/
|
|
13
|
-
export declare function ruleCompile(
|
|
15
|
+
export declare function ruleCompile(rule: Rule, options?: PatternCompileOptions): Rule;
|
|
14
16
|
/**
|
|
15
17
|
* @see {@link resolveSources}
|
|
16
18
|
*
|
|
@@ -26,10 +28,25 @@ export interface ResolveSourcesOptions extends PatternFinderOptions {
|
|
|
26
28
|
* @since 0.6.0
|
|
27
29
|
*/
|
|
28
30
|
dir: string;
|
|
31
|
+
/**
|
|
32
|
+
* Maps directory paths to their corresponding sources.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* "dir" => Resource
|
|
36
|
+
* "dir/subdir" => Resource
|
|
37
|
+
*
|
|
38
|
+
* @since 0.11.0
|
|
39
|
+
*/
|
|
40
|
+
external: Map<string, Resource>;
|
|
41
|
+
/**
|
|
42
|
+
* Directory entries of the current directory.
|
|
43
|
+
* Used for optimization to avoid redundant `fs.readFile` calls.
|
|
44
|
+
*
|
|
45
|
+
* @since 0.11.0
|
|
46
|
+
*/
|
|
47
|
+
entries?: Dirent[];
|
|
29
48
|
}
|
|
30
49
|
/**
|
|
31
|
-
* Populates the {@link MatcherContext.external} map with {@link Source} objects.
|
|
32
|
-
*
|
|
33
50
|
* @since 0.6.0
|
|
34
51
|
*/
|
|
35
|
-
export declare function resolveSources(options: ResolveSourcesOptions):
|
|
52
|
+
export declare function resolveSources(options: ResolveSourcesOptions, cb: (err: Error | null, resource: Resource) => void): void;
|