view-ignored 0.6.0 → 0.7.0
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/out/browser_scan.d.ts +1 -1
- package/out/browser_scan.js +14 -9
- package/out/browser_stream.d.ts +1 -1
- package/out/browser_stream.js +14 -9
- package/out/patterns/extractor.d.ts +10 -10
- package/out/patterns/gitignore.d.ts +1 -1
- package/out/patterns/gitignore.js +1 -1
- package/out/patterns/ignores.d.ts +1 -1
- package/out/patterns/jsrjson.d.ts +2 -2
- package/out/patterns/jsrjson.js +2 -2
- package/out/patterns/matcherContext.d.ts +8 -8
- package/out/patterns/matcherContextPatch.d.ts +2 -2
- package/out/patterns/matcherContextPatch.js +13 -8
- package/out/patterns/matcherStream.d.ts +9 -9
- package/out/patterns/matcherStream.js +1 -1
- package/out/patterns/packagejson.d.ts +1 -1
- package/out/patterns/packagejson.js +1 -1
- package/out/patterns/pattern.d.ts +6 -6
- package/out/patterns/pattern.js +2 -2
- package/out/patterns/patternMatcher.d.ts +3 -3
- package/out/patterns/resolveSources.d.ts +4 -4
- package/out/patterns/resolveSources.js +7 -14
- package/out/patterns/signedPattern.d.ts +21 -12
- package/out/patterns/signedPattern.js +60 -25
- package/out/patterns/source.d.ts +7 -7
- package/out/patterns/source.js +1 -1
- package/out/patterns/stringCompile.d.ts +1 -1
- package/out/patterns/stringCompile.js +1 -1
- package/out/scan.d.ts +1 -1
- package/out/scan.js +1 -1
- package/out/stream.d.ts +1 -1
- package/out/stream.js +1 -1
- package/out/targets/git.d.ts +1 -1
- package/out/targets/git.js +1 -1
- package/out/targets/jsr.d.ts +1 -1
- package/out/targets/jsr.js +1 -1
- package/out/targets/npm.d.ts +1 -1
- package/out/targets/npm.js +1 -1
- package/out/targets/target.d.ts +3 -3
- package/out/targets/vsce.d.ts +1 -1
- package/out/targets/vsce.js +1 -1
- package/out/targets/yarn.d.ts +1 -1
- package/out/targets/yarn.js +1 -1
- package/out/types.d.ts +11 -11
- package/out/walk.d.ts +1 -0
- package/out/walk.js +2 -5
- package/package.json +1 -1
package/out/browser_scan.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type * from "./types.js";
|
|
|
12
12
|
* @param options Scan options.
|
|
13
13
|
* @returns A promise that resolves to a {@link MatcherContext} containing the scan results.
|
|
14
14
|
*
|
|
15
|
-
* @since 0.0
|
|
15
|
+
* @since 0.6.0
|
|
16
16
|
*/
|
|
17
17
|
export declare function scan(options: ScanOptions & {
|
|
18
18
|
fs: FsAdapter;
|
package/out/browser_scan.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
|
+
import { relative } from "node:path/posix";
|
|
2
3
|
import { normalizeCwd } from "./normalizeCwd.js";
|
|
3
4
|
import { opendir } from "./opendir.js";
|
|
4
5
|
import { walkIncludes } from "./walk.js";
|
|
@@ -13,10 +14,10 @@ import { walkIncludes } from "./walk.js";
|
|
|
13
14
|
* @param options Scan options.
|
|
14
15
|
* @returns A promise that resolves to a {@link MatcherContext} containing the scan results.
|
|
15
16
|
*
|
|
16
|
-
* @since 0.0
|
|
17
|
+
* @since 0.6.0
|
|
17
18
|
*/
|
|
18
19
|
export function scan(options) {
|
|
19
|
-
const { target, cwd, within
|
|
20
|
+
const { target, cwd, within = ".", invert = false, depth: maxDepth = Infinity, signal = null, fastDepth = false, fastInternal = false, fs, } = options;
|
|
20
21
|
if (maxDepth < 0) {
|
|
21
22
|
throw new TypeError("Depth must be a non-negative integer");
|
|
22
23
|
}
|
|
@@ -32,7 +33,7 @@ export function scan(options) {
|
|
|
32
33
|
const normalCwd = normalizeCwd(cwd);
|
|
33
34
|
const scanOptions = {
|
|
34
35
|
cwd: normalCwd,
|
|
35
|
-
within
|
|
36
|
+
within,
|
|
36
37
|
depth: maxDepth,
|
|
37
38
|
fastDepth,
|
|
38
39
|
fastInternal,
|
|
@@ -41,12 +42,16 @@ export function scan(options) {
|
|
|
41
42
|
signal,
|
|
42
43
|
target,
|
|
43
44
|
};
|
|
44
|
-
const result = opendir(fs, resolve(normalCwd,
|
|
45
|
-
entry
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
const result = opendir(fs, normalizeCwd(resolve(normalCwd, within)), (entry) => {
|
|
46
|
+
const path = relative(normalCwd, normalizeCwd(entry.parentPath) + "/" + entry.name);
|
|
47
|
+
return walkIncludes({
|
|
48
|
+
path,
|
|
49
|
+
entry,
|
|
50
|
+
ctx,
|
|
51
|
+
stream: undefined,
|
|
52
|
+
scanOptions,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
50
55
|
return (async () => {
|
|
51
56
|
await result;
|
|
52
57
|
return ctx;
|
package/out/browser_stream.d.ts
CHANGED
package/out/browser_stream.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
|
+
import { relative } from "node:path/posix";
|
|
2
3
|
import { normalizeCwd } from "./normalizeCwd.js";
|
|
3
4
|
import { opendir } from "./opendir.js";
|
|
4
5
|
import { MatcherStream } from "./patterns/matcherStream.js";
|
|
@@ -6,10 +7,10 @@ import { walkIncludes } from "./walk.js";
|
|
|
6
7
|
/**
|
|
7
8
|
* @see {@link browserScan}
|
|
8
9
|
*
|
|
9
|
-
* @since 0.0
|
|
10
|
+
* @since 0.6.0
|
|
10
11
|
*/
|
|
11
12
|
export function scanStream(options) {
|
|
12
|
-
const { target, cwd, within
|
|
13
|
+
const { target, cwd, within = ".", invert = false, depth: maxDepth = Infinity, signal = null, fastDepth = false, fastInternal = false, fs, } = options;
|
|
13
14
|
const ctx = {
|
|
14
15
|
paths: new Map(),
|
|
15
16
|
external: new Map(),
|
|
@@ -23,7 +24,7 @@ export function scanStream(options) {
|
|
|
23
24
|
const normalCwd = normalizeCwd(cwd);
|
|
24
25
|
const scanOptions = {
|
|
25
26
|
cwd: normalCwd,
|
|
26
|
-
within
|
|
27
|
+
within,
|
|
27
28
|
depth: maxDepth,
|
|
28
29
|
fastDepth,
|
|
29
30
|
fastInternal,
|
|
@@ -32,12 +33,16 @@ export function scanStream(options) {
|
|
|
32
33
|
signal,
|
|
33
34
|
target,
|
|
34
35
|
};
|
|
35
|
-
const result = opendir(fs, resolve(normalCwd,
|
|
36
|
-
entry
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const result = opendir(fs, normalizeCwd(resolve(normalCwd, within)), (entry) => {
|
|
37
|
+
const path = relative(normalCwd, normalizeCwd(entry.parentPath) + "/" + entry.name);
|
|
38
|
+
return walkIncludes({
|
|
39
|
+
path,
|
|
40
|
+
entry,
|
|
41
|
+
ctx,
|
|
42
|
+
stream,
|
|
43
|
+
scanOptions,
|
|
44
|
+
});
|
|
45
|
+
});
|
|
41
46
|
void (async () => {
|
|
42
47
|
await result;
|
|
43
48
|
stream.emit("end", ctx);
|
|
@@ -10,13 +10,13 @@ import type { Source } from "./source.js";
|
|
|
10
10
|
* @see {@link Source.pattern} for more details.
|
|
11
11
|
* @throws Error if extraction fails. Processing stops.
|
|
12
12
|
*
|
|
13
|
-
* @since 0.0
|
|
13
|
+
* @since 0.6.0
|
|
14
14
|
*/
|
|
15
15
|
export type ExtractorFn = (source: Source, content: Buffer, ctx: MatcherContext) => void | "none";
|
|
16
16
|
/**
|
|
17
17
|
* Defines a method for extracting patterns from a specific source file.
|
|
18
18
|
*
|
|
19
|
-
* @since 0.0
|
|
19
|
+
* @since 0.6.0
|
|
20
20
|
*/
|
|
21
21
|
export interface Extractor {
|
|
22
22
|
/**
|
|
@@ -25,7 +25,7 @@ export interface Extractor {
|
|
|
25
25
|
* @example
|
|
26
26
|
* ".gitignore"
|
|
27
27
|
*
|
|
28
|
-
* @since 0.0
|
|
28
|
+
* @since 0.6.0
|
|
29
29
|
*/
|
|
30
30
|
path: string;
|
|
31
31
|
/**
|
|
@@ -33,7 +33,7 @@ export interface Extractor {
|
|
|
33
33
|
*
|
|
34
34
|
* @see {@link ExtractorFn}
|
|
35
35
|
*
|
|
36
|
-
* @since 0.0
|
|
36
|
+
* @since 0.6.0
|
|
37
37
|
*/
|
|
38
38
|
extract: ExtractorFn;
|
|
39
39
|
}
|
|
@@ -43,38 +43,38 @@ export interface Extractor {
|
|
|
43
43
|
* @see {@link resolveSources}
|
|
44
44
|
* @see {@link signedPatternIgnores}
|
|
45
45
|
*
|
|
46
|
-
* @since 0.0
|
|
46
|
+
* @since 0.6.0
|
|
47
47
|
*/
|
|
48
48
|
export interface PatternFinderOptions {
|
|
49
49
|
/**
|
|
50
50
|
* The file system adapter for directory walking and reading files.
|
|
51
51
|
*
|
|
52
|
-
* @since 0.0
|
|
52
|
+
* @since 0.6.0
|
|
53
53
|
*/
|
|
54
54
|
fs: FsAdapter;
|
|
55
55
|
/**
|
|
56
56
|
* The context to modify.
|
|
57
57
|
*
|
|
58
|
-
* @since 0.0
|
|
58
|
+
* @since 0.6.0
|
|
59
59
|
*/
|
|
60
60
|
ctx: MatcherContext;
|
|
61
61
|
/**
|
|
62
62
|
* The current working directory.
|
|
63
63
|
*
|
|
64
|
-
* @since 0.0
|
|
64
|
+
* @since 0.6.0
|
|
65
65
|
*/
|
|
66
66
|
cwd: string;
|
|
67
67
|
/**
|
|
68
68
|
* The target implementation.
|
|
69
69
|
*
|
|
70
|
-
* @since 0.0
|
|
70
|
+
* @since 0.6.0
|
|
71
71
|
*/
|
|
72
72
|
target: Target;
|
|
73
73
|
/**
|
|
74
74
|
* Initial search directory.
|
|
75
75
|
* Relative to the `cwd` path or absolute path.
|
|
76
76
|
*
|
|
77
|
-
* @since 0.0
|
|
77
|
+
* @since 0.6.0
|
|
78
78
|
*/
|
|
79
79
|
root: string;
|
|
80
80
|
}
|
|
@@ -14,6 +14,6 @@ export interface IgnoresOptions {
|
|
|
14
14
|
* @see {@link signedPatternIgnores}
|
|
15
15
|
* @see {@link https://github.com/Mopsgamer/view-ignored/tree/main/src/targets} for usage examples.
|
|
16
16
|
*
|
|
17
|
-
* @since 0.0
|
|
17
|
+
* @since 0.6.0
|
|
18
18
|
*/
|
|
19
19
|
export type Ignores = (options: IgnoresOptions) => Promise<SignedPatternMatch>;
|
|
@@ -3,7 +3,7 @@ import type { Source } from "./source.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Extracts and compiles patterns from the file.
|
|
5
5
|
*
|
|
6
|
-
* @since 0.0
|
|
6
|
+
* @since 0.6.0
|
|
7
7
|
*/
|
|
8
8
|
export declare function extractJsrJson(source: Source, content: Buffer, ctx: MatcherContext): void;
|
|
9
9
|
/**
|
|
@@ -11,6 +11,6 @@ export declare function extractJsrJson(source: Source, content: Buffer, ctx: Mat
|
|
|
11
11
|
*
|
|
12
12
|
* @see {@link signedPatternCompile}
|
|
13
13
|
*
|
|
14
|
-
* @since 0.0
|
|
14
|
+
* @since 0.6.0
|
|
15
15
|
*/
|
|
16
16
|
export declare function extractJsrJsonc(source: Source, content: Buffer, ctx: MatcherContext): void;
|
package/out/patterns/jsrjson.js
CHANGED
|
@@ -15,7 +15,7 @@ const parse = type("string")
|
|
|
15
15
|
/**
|
|
16
16
|
* Extracts and compiles patterns from the file.
|
|
17
17
|
*
|
|
18
|
-
* @since 0.0
|
|
18
|
+
* @since 0.6.0
|
|
19
19
|
*/
|
|
20
20
|
export function extractJsrJson(source, content, ctx) {
|
|
21
21
|
const dist = parse(content.toString());
|
|
@@ -48,7 +48,7 @@ extractJsrJson;
|
|
|
48
48
|
*
|
|
49
49
|
* @see {@link signedPatternCompile}
|
|
50
50
|
*
|
|
51
|
-
* @since 0.0
|
|
51
|
+
* @since 0.6.0
|
|
52
52
|
*/
|
|
53
53
|
export function extractJsrJsonc(source, content, ctx) {
|
|
54
54
|
extractJsrJson(source, Buffer.from(stripJsonComments(content.toString())), ctx);
|
|
@@ -3,14 +3,14 @@ import type { Source } from "./source.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Post-scan results.
|
|
5
5
|
*
|
|
6
|
-
* @since 0.0
|
|
6
|
+
* @since 0.6.0
|
|
7
7
|
*/
|
|
8
8
|
export interface MatcherContext {
|
|
9
9
|
/**
|
|
10
10
|
* Paths and their corresponding sources.
|
|
11
11
|
* Directory paths are having the slash suffix.
|
|
12
12
|
*
|
|
13
|
-
* @since 0.0
|
|
13
|
+
* @since 0.6.0
|
|
14
14
|
*/
|
|
15
15
|
paths: Map<string, SignedPatternMatch>;
|
|
16
16
|
/**
|
|
@@ -20,14 +20,14 @@ export interface MatcherContext {
|
|
|
20
20
|
* "dir" => Source
|
|
21
21
|
* "dir/subdir" => Source
|
|
22
22
|
*
|
|
23
|
-
* @since 0.0
|
|
23
|
+
* @since 0.6.0
|
|
24
24
|
*/
|
|
25
25
|
external: Map<string, Source | "none">;
|
|
26
26
|
/**
|
|
27
27
|
* If any fatal errors were encountered during source extractions,
|
|
28
28
|
* this property will contain an array of failed sources.
|
|
29
29
|
*
|
|
30
|
-
* @since 0.0
|
|
30
|
+
* @since 0.6.0
|
|
31
31
|
*/
|
|
32
32
|
failed: Source[];
|
|
33
33
|
/**
|
|
@@ -47,25 +47,25 @@ export interface MatcherContext {
|
|
|
47
47
|
* "src/components" => 0
|
|
48
48
|
* "src/views" => 1
|
|
49
49
|
*
|
|
50
|
-
* @since 0.0
|
|
50
|
+
* @since 0.6.0
|
|
51
51
|
*/
|
|
52
52
|
depthPaths: Map<string, number>;
|
|
53
53
|
/**
|
|
54
54
|
* Total number of files scanned.
|
|
55
55
|
*
|
|
56
|
-
* @since 0.0
|
|
56
|
+
* @since 0.6.0
|
|
57
57
|
*/
|
|
58
58
|
totalFiles: number;
|
|
59
59
|
/**
|
|
60
60
|
* Total number of files matched by the target.
|
|
61
61
|
*
|
|
62
|
-
* @since 0.0
|
|
62
|
+
* @since 0.6.0
|
|
63
63
|
*/
|
|
64
64
|
totalMatchedFiles: number;
|
|
65
65
|
/**
|
|
66
66
|
* Total number of directories scanned.
|
|
67
67
|
*
|
|
68
|
-
* @since 0.0
|
|
68
|
+
* @since 0.6.0
|
|
69
69
|
*/
|
|
70
70
|
totalDirs: number;
|
|
71
71
|
}
|
|
@@ -4,13 +4,13 @@ import type { MatcherContext } from "./matcherContext.js";
|
|
|
4
4
|
* Provides patching abilities for the given {@link MatcherContext}.
|
|
5
5
|
* Directories should have the slash suffix.
|
|
6
6
|
*
|
|
7
|
-
* @since 0.0
|
|
7
|
+
* @since 0.6.0
|
|
8
8
|
*/
|
|
9
9
|
export declare function matcherContextAddPath(ctx: MatcherContext, options: Required<ScanOptions>, entry: string): Promise<boolean>;
|
|
10
10
|
/**
|
|
11
11
|
* Provides patching abilities for the given {@link MatcherContext}.
|
|
12
12
|
* Directories should have the slash suffix.
|
|
13
13
|
*
|
|
14
|
-
* @since 0.0
|
|
14
|
+
* @since 0.6.0
|
|
15
15
|
*/
|
|
16
16
|
export declare function matcherContextRemovePath(ctx: MatcherContext, options: Required<ScanOptions>, entry: string): Promise<boolean>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolve, dirname } from "node:path";
|
|
2
|
+
import { relative } from "node:path/posix";
|
|
2
3
|
import { getDepth } from "../getDepth.js";
|
|
3
4
|
import { normalizeCwd } from "../normalizeCwd.js";
|
|
4
5
|
import { opendir } from "../opendir.js";
|
|
@@ -7,7 +8,7 @@ import { walkIncludes } from "../walk.js";
|
|
|
7
8
|
* Provides patching abilities for the given {@link MatcherContext}.
|
|
8
9
|
* Directories should have the slash suffix.
|
|
9
10
|
*
|
|
10
|
-
* @since 0.0
|
|
11
|
+
* @since 0.6.0
|
|
11
12
|
*/
|
|
12
13
|
export async function matcherContextAddPath(ctx, options, entry) {
|
|
13
14
|
if (ctx.paths.has(entry)) {
|
|
@@ -60,7 +61,7 @@ export async function matcherContextAddPath(ctx, options, entry) {
|
|
|
60
61
|
* Provides patching abilities for the given {@link MatcherContext}.
|
|
61
62
|
* Directories should have the slash suffix.
|
|
62
63
|
*
|
|
63
|
-
* @since 0.0
|
|
64
|
+
* @since 0.6.0
|
|
64
65
|
*/
|
|
65
66
|
export async function matcherContextRemovePath(ctx, options, entry) {
|
|
66
67
|
const isDir = entry.endsWith("/");
|
|
@@ -141,11 +142,15 @@ export async function matcherContextRemovePath(ctx, options, entry) {
|
|
|
141
142
|
}
|
|
142
143
|
async function rescan(ctx, options) {
|
|
143
144
|
const normalCwd = normalizeCwd(options.cwd);
|
|
144
|
-
await opendir(options.fs, resolve(normalCwd, options.within), (entry) =>
|
|
145
|
-
entry
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
await opendir(options.fs, resolve(normalCwd, options.within), (entry) => {
|
|
146
|
+
const path = relative(normalCwd, normalizeCwd(entry.parentPath) + "/" + entry.name);
|
|
147
|
+
return walkIncludes({
|
|
148
|
+
path,
|
|
149
|
+
entry,
|
|
150
|
+
ctx,
|
|
151
|
+
stream: undefined,
|
|
152
|
+
scanOptions: { ...options, cwd: normalCwd },
|
|
153
|
+
});
|
|
154
|
+
});
|
|
150
155
|
ctx.totalDirs = ctx.totalFiles = ctx.totalMatchedFiles = -1;
|
|
151
156
|
}
|
|
@@ -5,50 +5,50 @@ import type { SignedPatternMatch } from "./signedPattern.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* Post-scan entry information.
|
|
7
7
|
*
|
|
8
|
-
* @since 0.0
|
|
8
|
+
* @since 0.6.0
|
|
9
9
|
*/
|
|
10
10
|
export type EntryInfo = {
|
|
11
11
|
/**
|
|
12
12
|
* The relative path of the entry.
|
|
13
13
|
*
|
|
14
|
-
* @since 0.0
|
|
14
|
+
* @since 0.6.0
|
|
15
15
|
*/
|
|
16
16
|
path: string;
|
|
17
17
|
/**
|
|
18
18
|
* The directory entry.
|
|
19
19
|
*
|
|
20
|
-
* @since 0.0
|
|
20
|
+
* @since 0.6.0
|
|
21
21
|
*/
|
|
22
22
|
dirent: Dirent;
|
|
23
23
|
/**
|
|
24
24
|
* Whether the entry was ignored.
|
|
25
25
|
*
|
|
26
|
-
* @since 0.0
|
|
26
|
+
* @since 0.6.0
|
|
27
27
|
*/
|
|
28
28
|
match: SignedPatternMatch;
|
|
29
29
|
/**
|
|
30
30
|
* The matcher context.
|
|
31
31
|
*
|
|
32
|
-
* @since 0.0
|
|
32
|
+
* @since 0.6.0
|
|
33
33
|
*/
|
|
34
34
|
ctx: MatcherContext;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
37
|
* @see {@link MatcherStream} uses it for the "dirent" event.
|
|
38
38
|
*
|
|
39
|
-
* @since 0.0
|
|
39
|
+
* @since 0.6.0
|
|
40
40
|
*/
|
|
41
41
|
export type EntryListener = (info: EntryInfo) => void;
|
|
42
42
|
/**
|
|
43
43
|
* @see {@link MatcherStream} uses it for the "end" event.
|
|
44
44
|
*
|
|
45
|
-
* @since 0.0
|
|
45
|
+
* @since 0.6.0
|
|
46
46
|
*/
|
|
47
47
|
export type EndListener = (ctx: MatcherContext) => void;
|
|
48
48
|
/**
|
|
49
49
|
* @see {@link MatcherStream} uses it for its event map.
|
|
50
50
|
*
|
|
51
|
-
* @since 0.0
|
|
51
|
+
* @since 0.6.0
|
|
52
52
|
*/
|
|
53
53
|
export type EventMap = {
|
|
54
54
|
dirent: [EntryInfo];
|
|
@@ -58,7 +58,7 @@ export type EventMap = {
|
|
|
58
58
|
* Event emitter.
|
|
59
59
|
* @extends EventEmitter
|
|
60
60
|
*
|
|
61
|
-
* @since 0.0
|
|
61
|
+
* @since 0.6.0
|
|
62
62
|
*/
|
|
63
63
|
export declare class MatcherStream extends EventEmitter<EventMap> {
|
|
64
64
|
}
|
|
@@ -4,33 +4,33 @@
|
|
|
4
4
|
* @see {@link stringCompile}
|
|
5
5
|
* @see {@link signedPatternCompile}
|
|
6
6
|
*
|
|
7
|
-
* @since 0.0
|
|
7
|
+
* @since 0.6.0
|
|
8
8
|
*/
|
|
9
9
|
export type PatternMinimatch = {
|
|
10
10
|
re: RegExp;
|
|
11
11
|
/**
|
|
12
12
|
* The original pattern string this minimatch was compiled from.
|
|
13
13
|
*
|
|
14
|
-
* @since 0.0
|
|
14
|
+
* @since 0.6.0
|
|
15
15
|
*/
|
|
16
16
|
pattern: string;
|
|
17
17
|
/**
|
|
18
18
|
* The original pattern list this pattern was compiled from.
|
|
19
19
|
*
|
|
20
|
-
* @since 0.0
|
|
20
|
+
* @since 0.6.0
|
|
21
21
|
*/
|
|
22
22
|
patternContext: Pattern;
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
25
|
* Safely calls RegExp.test.
|
|
26
26
|
*
|
|
27
|
-
* @since 0.0
|
|
27
|
+
* @since 0.6.0
|
|
28
28
|
*/
|
|
29
29
|
export declare function patternMinimatchTest(pattern: PatternMinimatch, path: string): boolean;
|
|
30
30
|
/**
|
|
31
31
|
* Represents a list of positive minimatch patterns.
|
|
32
32
|
*
|
|
33
|
-
* @since 0.0
|
|
33
|
+
* @since 0.6.0
|
|
34
34
|
*/
|
|
35
35
|
export type Pattern = string[];
|
|
36
36
|
/**
|
|
@@ -39,6 +39,6 @@ export type Pattern = string[];
|
|
|
39
39
|
* @see {@link stringCompile}
|
|
40
40
|
* @see {@link signedPatternCompile}
|
|
41
41
|
*
|
|
42
|
-
* @since 0.0
|
|
42
|
+
* @since 0.6.0
|
|
43
43
|
*/
|
|
44
44
|
export declare function patternCompile(pattern: Pattern): PatternMinimatch[];
|
package/out/patterns/pattern.js
CHANGED
|
@@ -2,7 +2,7 @@ import { stringCompile } from "./stringCompile.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Safely calls RegExp.test.
|
|
4
4
|
*
|
|
5
|
-
* @since 0.0
|
|
5
|
+
* @since 0.6.0
|
|
6
6
|
*/
|
|
7
7
|
export function patternMinimatchTest(pattern, path) {
|
|
8
8
|
pattern.re.lastIndex = 0;
|
|
@@ -14,7 +14,7 @@ export function patternMinimatchTest(pattern, path) {
|
|
|
14
14
|
* @see {@link stringCompile}
|
|
15
15
|
* @see {@link signedPatternCompile}
|
|
16
16
|
*
|
|
17
|
-
* @since 0.0
|
|
17
|
+
* @since 0.6.0
|
|
18
18
|
*/
|
|
19
19
|
export function patternCompile(pattern) {
|
|
20
20
|
return pattern.map(stringCompile);
|
|
@@ -4,20 +4,20 @@ import type { SignedPattern } from "./signedPattern.js";
|
|
|
4
4
|
*
|
|
5
5
|
* @see {@link signedPatternIgnores}
|
|
6
6
|
*
|
|
7
|
-
* @since 0.0
|
|
7
|
+
* @since 0.6.0
|
|
8
8
|
*/
|
|
9
9
|
export type PatternMatcher = {
|
|
10
10
|
/**
|
|
11
11
|
* Internal patterns are provided by the target.
|
|
12
12
|
* Almost always they are predefined.
|
|
13
13
|
*
|
|
14
|
-
* @since 0.0
|
|
14
|
+
* @since 0.6.0
|
|
15
15
|
*/
|
|
16
16
|
internal: SignedPattern;
|
|
17
17
|
/**
|
|
18
18
|
* External patterns are sourced from existing project files at runtime.
|
|
19
19
|
*
|
|
20
|
-
* @since 0.0
|
|
20
|
+
* @since 0.6.0
|
|
21
21
|
*/
|
|
22
22
|
external: SignedPattern;
|
|
23
23
|
};
|
|
@@ -7,13 +7,13 @@ import type { SignedPattern } from "./signedPattern.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @see {@link patternCompile}
|
|
9
9
|
*
|
|
10
|
-
* @since 0.0
|
|
10
|
+
* @since 0.6.0
|
|
11
11
|
*/
|
|
12
12
|
export declare function signedPatternCompile(signedPattern: SignedPattern): SignedPattern;
|
|
13
13
|
/**
|
|
14
14
|
* @see {@link resolveSources}
|
|
15
15
|
*
|
|
16
|
-
* @since 0.0
|
|
16
|
+
* @since 0.6.0
|
|
17
17
|
*/
|
|
18
18
|
export interface ResolveSourcesOptions extends PatternFinderOptions {
|
|
19
19
|
/**
|
|
@@ -22,13 +22,13 @@ export interface ResolveSourcesOptions extends PatternFinderOptions {
|
|
|
22
22
|
* @example
|
|
23
23
|
* "dir/subdir"
|
|
24
24
|
*
|
|
25
|
-
* @since 0.0
|
|
25
|
+
* @since 0.6.0
|
|
26
26
|
*/
|
|
27
27
|
dir: string;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Populates the {@link MatcherContext.external} map with {@link Source} objects.
|
|
31
31
|
*
|
|
32
|
-
* @since 0.0
|
|
32
|
+
* @since 0.6.0
|
|
33
33
|
*/
|
|
34
34
|
export declare function resolveSources(options: ResolveSourcesOptions): Promise<void>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { dirname, relative, resolve } from "node:path";
|
|
2
|
-
import { normalizeCwd } from "../normalizeCwd.js";
|
|
3
2
|
import { patternCompile } from "./pattern.js";
|
|
4
3
|
/**
|
|
5
4
|
* Compiles the {@link SignedPattern} (forced).
|
|
@@ -8,7 +7,7 @@ import { patternCompile } from "./pattern.js";
|
|
|
8
7
|
*
|
|
9
8
|
* @see {@link patternCompile}
|
|
10
9
|
*
|
|
11
|
-
* @since 0.0
|
|
10
|
+
* @since 0.6.0
|
|
12
11
|
*/
|
|
13
12
|
export function signedPatternCompile(signedPattern) {
|
|
14
13
|
signedPattern.compiled = {
|
|
@@ -20,7 +19,7 @@ export function signedPatternCompile(signedPattern) {
|
|
|
20
19
|
/**
|
|
21
20
|
* Populates the {@link MatcherContext.external} map with {@link Source} objects.
|
|
22
21
|
*
|
|
23
|
-
* @since 0.0
|
|
22
|
+
* @since 0.6.0
|
|
24
23
|
*/
|
|
25
24
|
export async function resolveSources(options) {
|
|
26
25
|
const { fs, ctx, cwd, target, root } = options;
|
|
@@ -71,7 +70,7 @@ export async function resolveSources(options) {
|
|
|
71
70
|
ctx.external.set(noSourceDir, source);
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
|
-
const rels = noSourceDirList.map((rel) =>
|
|
73
|
+
const rels = noSourceDirList.map((rel) => resolve(cwd, rel).replaceAll("\\", "/").replace(/\w:/, ""));
|
|
75
74
|
source = await findSourceForAbsoluteDirs(rels, ctx, fs, target);
|
|
76
75
|
if (source !== undefined) {
|
|
77
76
|
for (const noSourceDir of noSourceDirList) {
|
|
@@ -80,25 +79,19 @@ export async function resolveSources(options) {
|
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
async function findSourceForAbsoluteDirs(paths, ctx, fs, target) {
|
|
83
|
-
let source;
|
|
84
82
|
for (const parent of paths) {
|
|
85
83
|
for (const extractor of target.extractors) {
|
|
86
84
|
const s = await tryExtractor(parent, fs, ctx, extractor);
|
|
87
85
|
if (typeof s === "object" && s.error) {
|
|
88
86
|
ctx.failed.push(s);
|
|
89
|
-
|
|
87
|
+
return s;
|
|
90
88
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
continue;
|
|
89
|
+
if (typeof s === "object") {
|
|
90
|
+
return s;
|
|
94
91
|
}
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
if (source !== undefined) {
|
|
98
|
-
break;
|
|
99
92
|
}
|
|
100
93
|
}
|
|
101
|
-
return
|
|
94
|
+
return "none";
|
|
102
95
|
}
|
|
103
96
|
async function tryExtractor(cwd, fs, ctx, extractor) {
|
|
104
97
|
const abs = resolve(cwd, extractor.path);
|