view-ignored 0.8.1 → 0.9.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 CHANGED
@@ -146,28 +146,30 @@ The following built-in scanners are available:
146
146
  - Check this scanner by running `git ls-files --others --exclude-standard --cached`.
147
147
  - NPM ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/npm.ts))
148
148
  - Expecting to be compatible with PNPM, and others.
149
+ - Validates `package.json`.
149
150
  - Reads `package.json` `files` field, `.npmignore` and `.gitignore`.
150
151
  - Starts searching from `.` (current working directory).
151
- - No additional checks for `name`, `version` or `publishConfig`.
152
152
  - Check this scanner by running `npm pack --dry-run`.
153
153
  - Bun ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/bun.ts))
154
154
  - Bun tries to mimic NPM, but that does not mean it behaves the same way.
155
155
  - Check this scanner by running `bun pm pack --dry-run`.
156
156
  - Yarn ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/yarn.ts))
157
157
  - Modern Berry behavior.
158
+ - Validates `package.json`.
158
159
  - Reads `package.json` `files` field, `.npmignore` and `.gitignore`.
159
160
  - Requires `package.json`: includes paths from `main`, `module`, `browser` and `bin`.
160
161
  - Starts searching from `.` (current working directory).
161
162
  - `YarnClassic` is available. ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/yarnClassic.ts))
162
163
  - VSCE ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/vsce.ts))
164
+ - Validates `package.json`.
163
165
  - Reads `package.json` `files` field, `.vscodeignore` and `.gitignore`.
164
166
  - Starts searching from `.` (current working directory).
165
167
  - Check this scanner by running `vsce ls`.
166
168
  - JSR ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/jsr.ts))
167
- - Reads `jsr.json(c)` `include` and `exclude` fields.
169
+ - Validates and reads `jsr.json(c)` `include` and `exclude` fields.
168
170
  - Starts searching from `.` (current working directory).
169
171
  - Deno ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/deno.ts))
170
- - Reads `jsr.json(c)` and `deno.json(c)` `include` and `exclude` fields.
172
+ - Validates and reads `jsr.json(c)` and `deno.json(c)` `include` and `exclude` fields.
171
173
  - Starts searching from `.` (current working directory).
172
174
 
173
175
  ## See also
@@ -1,5 +1,5 @@
1
- import { MatcherStream } from "./patterns/matcherStream.js";
2
1
  import type { ScanOptions, FsAdapter } from "./types.js";
2
+ import { MatcherStream } from "./patterns/matcherStream.js";
3
3
  export type * from "./types.js";
4
4
  /**
5
5
  * @see {@link browserScan}
@@ -9,7 +9,9 @@ import { sourcePushNegatable } from "./source.js";
9
9
  */
10
10
  export function extractGitignore(source, content) {
11
11
  extract(source, content);
12
- signedPatternCompile(source.pattern);
12
+ for (const element of source.pattern) {
13
+ signedPatternCompile(element);
14
+ }
13
15
  }
14
16
  /**
15
17
  * Extracts and compiles patterns from the file.
@@ -20,10 +22,14 @@ export function extractGitignore(source, content) {
20
22
  */
21
23
  export function extractGitignoreNocase(source, content) {
22
24
  extract(source, content);
23
- signedPatternCompile(source.pattern, { nocase: true });
25
+ for (const element of source.pattern) {
26
+ signedPatternCompile(element, { nocase: true });
27
+ }
24
28
  }
25
29
  extractGitignore;
26
30
  function extract(source, content) {
31
+ const include = { compiled: null, excludes: false, pattern: [] };
32
+ const exclude = { compiled: null, excludes: true, pattern: [] };
27
33
  for (let line of content.toString().split("\n")) {
28
34
  line = line.trim();
29
35
  if (line === "" || line.startsWith("#")) {
@@ -33,6 +39,7 @@ function extract(source, content) {
33
39
  if (cdx >= 0) {
34
40
  line = line.substring(-cdx);
35
41
  }
36
- sourcePushNegatable(source, line);
42
+ sourcePushNegatable(line, false, include, exclude);
37
43
  }
44
+ source.pattern.push(include, exclude);
38
45
  }
@@ -9,7 +9,6 @@ export * from "./matcherContextPatch.js";
9
9
  export * from "./matcherStream.js";
10
10
  export * from "./packagejson.js";
11
11
  export * from "./pattern.js";
12
- export * from "./patternMatcher.js";
13
12
  export * from "./resolveSources.js";
14
13
  export * from "./signedPattern.js";
15
14
  export * from "./source.js";
@@ -9,7 +9,6 @@ export * from "./matcherContextPatch.js";
9
9
  export * from "./matcherStream.js";
10
10
  export * from "./packagejson.js";
11
11
  export * from "./pattern.js";
12
- export * from "./patternMatcher.js";
13
12
  export * from "./resolveSources.js";
14
13
  export * from "./signedPattern.js";
15
14
  export * from "./source.js";
@@ -1,5 +1,5 @@
1
1
  import type { MatcherContext } from "./matcherContext.js";
2
- import type { Source } from "./source.js";
2
+ import { type Source } from "./source.js";
3
3
  /**
4
4
  * Extracts and compiles patterns from the file.
5
5
  *
@@ -1,6 +1,7 @@
1
1
  import { type } from "arktype";
2
2
  import stripJsonComments from "strip-json-comments";
3
3
  import { signedPatternCompile } from "./resolveSources.js";
4
+ import { sourcePushNegatable } from "./source.js";
4
5
  const jsrManifest = type({
5
6
  exclude: "string[]?",
6
7
  include: "string[]?",
@@ -18,7 +19,27 @@ const parse = type("string")
18
19
  * @since 0.6.0
19
20
  */
20
21
  export function extractJsrJson(source, content, ctx) {
22
+ extract(source, content, ctx);
23
+ for (const element of source.pattern) {
24
+ signedPatternCompile(element);
25
+ }
26
+ }
27
+ extractJsrJson;
28
+ /**
29
+ * Extracts and compiles patterns from the file.
30
+ *
31
+ * @see {@link signedPatternCompile}
32
+ *
33
+ * @since 0.6.0
34
+ */
35
+ export function extractJsrJsonc(source, content, ctx) {
36
+ extractJsrJson(source, Buffer.from(stripJsonComments(content.toString())), ctx);
37
+ }
38
+ extractJsrJsonc;
39
+ function extract(source, content, ctx) {
21
40
  const dist = parse(content.toString());
41
+ const include = { compiled: null, excludes: false, pattern: [] };
42
+ const exclude = { compiled: null, excludes: true, pattern: [] };
22
43
  if (dist instanceof type.errors) {
23
44
  source.error = new Error("Invalid '" + source.path + "': " + dist.summary, { cause: dist });
24
45
  ctx.failed.push(source);
@@ -26,31 +47,24 @@ export function extractJsrJson(source, content, ctx) {
26
47
  }
27
48
  if (!dist.publish) {
28
49
  if (dist.exclude) {
29
- source.pattern.exclude.push(...dist.exclude);
50
+ exclude.pattern.push(...dist.exclude);
30
51
  }
31
52
  }
32
53
  else if (dist.publish.exclude) {
33
- source.pattern.exclude.push(...dist.publish.exclude);
54
+ exclude.pattern.push(...dist.publish.exclude);
34
55
  }
35
56
  if (!dist.publish) {
36
57
  if (dist.include) {
37
- source.pattern.include.push(...dist.include);
58
+ include.pattern.push(...dist.include);
38
59
  }
39
60
  }
40
61
  else if (dist.publish.include) {
41
- source.pattern.include.push(...dist.publish.include);
62
+ include.pattern.push(...dist.publish.include);
42
63
  }
43
- signedPatternCompile(source.pattern);
44
- }
45
- extractJsrJson;
46
- /**
47
- * Extracts and compiles patterns from the file.
48
- *
49
- * @see {@link signedPatternCompile}
50
- *
51
- * @since 0.6.0
52
- */
53
- export function extractJsrJsonc(source, content, ctx) {
54
- extractJsrJson(source, Buffer.from(stripJsonComments(content.toString())), ctx);
64
+ for (const si of [include, exclude]) {
65
+ for (const pattern of si.pattern) {
66
+ sourcePushNegatable(pattern, true, include, exclude);
67
+ }
68
+ }
69
+ source.pattern.push(include, exclude);
55
70
  }
56
- extractJsrJsonc;
@@ -1,5 +1,5 @@
1
- import { EventEmitter } from "node:events";
2
1
  import type { Dirent } from "node:fs";
2
+ import { EventEmitter } from "node:events";
3
3
  import type { MatcherContext } from "../patterns/matcherContext.js";
4
4
  import type { ScanOptions, FsAdapter } from "../types.js";
5
5
  import type { SignedPatternMatch } from "./signedPattern.js";
@@ -1,12 +1,7 @@
1
1
  import { type } from "arktype";
2
+ import { npmManifestParse } from "../targets/npmManifest.js";
2
3
  import { signedPatternCompile } from "./resolveSources.js";
3
4
  import { sourcePushNegatable } from "./source.js";
4
- const npmManifest = type({
5
- "files?": "string[]",
6
- });
7
- const parse = type("string")
8
- .pipe((s) => JSON.parse(s))
9
- .pipe(npmManifest);
10
5
  /**
11
6
  * Extracts and compiles patterns from the file.
12
7
  *
@@ -16,8 +11,11 @@ const parse = type("string")
16
11
  */
17
12
  export function extractPackageJson(source, content) {
18
13
  const result = extract(source, content);
19
- if (result === undefined)
20
- signedPatternCompile(source.pattern);
14
+ if (result === undefined) {
15
+ for (const element of source.pattern) {
16
+ signedPatternCompile(element);
17
+ }
18
+ }
21
19
  if (result === "error")
22
20
  return;
23
21
  return result;
@@ -31,15 +29,20 @@ export function extractPackageJson(source, content) {
31
29
  */
32
30
  export function extractPackageJsonNocase(source, content) {
33
31
  const result = extract(source, content);
34
- if (result === undefined)
35
- signedPatternCompile(source.pattern, { nocase: true });
32
+ if (result === undefined) {
33
+ for (const element of source.pattern) {
34
+ signedPatternCompile(element, { nocase: true });
35
+ }
36
+ }
36
37
  if (result === "error")
37
38
  return;
38
39
  return result;
39
40
  }
40
41
  function extract(source, content) {
41
42
  source.inverted = true;
42
- const dist = parse(content.toString());
43
+ const include = { compiled: null, excludes: false, pattern: [] };
44
+ const exclude = { compiled: null, excludes: true, pattern: [] };
45
+ const dist = npmManifestParse(content.toString());
43
46
  if (dist instanceof type.errors) {
44
47
  source.error = new Error("Invalid '" + source.path + "': " + dist.summary, { cause: dist });
45
48
  return "error";
@@ -48,7 +51,8 @@ function extract(source, content) {
48
51
  return "none";
49
52
  }
50
53
  for (const pattern of dist.files) {
51
- sourcePushNegatable(source, pattern);
54
+ sourcePushNegatable(pattern, true, include, exclude);
52
55
  }
56
+ source.pattern.push(include, exclude);
53
57
  }
54
58
  extractPackageJson;
@@ -8,6 +8,11 @@ import { type StringCompileOptions } from "./stringCompile.js";
8
8
  * @since 0.6.0
9
9
  */
10
10
  export type PatternMinimatch = {
11
+ /**
12
+ * The regular expression instance.
13
+ *
14
+ * @since 0.6.0
15
+ */
11
16
  re: RegExp;
12
17
  /**
13
18
  * The original pattern string this minimatch was compiled from.
@@ -11,10 +11,7 @@ import { patternCompile } from "./pattern.js";
11
11
  * @since 0.6.0
12
12
  */
13
13
  export function signedPatternCompile(signedPattern, options) {
14
- signedPattern.compiled = {
15
- include: patternCompile(signedPattern.include, options),
16
- exclude: patternCompile(signedPattern.exclude, options),
17
- };
14
+ signedPattern.compiled = patternCompile(signedPattern.pattern, options);
18
15
  return signedPattern;
19
16
  }
20
17
  /**
@@ -110,10 +107,10 @@ async function tryExtractor(cwd, fs, ctx, extractor) {
110
107
  const path = relative(cwd, abs);
111
108
  const name = path.substring(path.lastIndexOf("/") + 1);
112
109
  const newSource = {
113
- inverted: false,
114
110
  name,
115
111
  path,
116
- pattern: { exclude: [], include: [], compiled: null },
112
+ inverted: false,
113
+ pattern: [],
117
114
  };
118
115
  let buff;
119
116
  try {
@@ -1,11 +1,10 @@
1
1
  import type { PatternFinderOptions } from "./extractor.js";
2
- import { type Pattern, type PatternMinimatch } from "./pattern.js";
3
2
  import type { Source } from "./source.js";
3
+ import { type Pattern, type PatternMinimatch } from "./pattern.js";
4
4
  /**
5
5
  * Represents a set of include and exclude patterns.
6
6
  * These patterns are positive minimatch patterns.
7
7
  *
8
- * @see {@link PatternMatcher} uses it.
9
8
  * @see {@link signedPatternIgnores} provides the ignoring algorithm.
10
9
  * @see {@link signedPatternCompile} compiles the signed pattern.
11
10
  * Use this or an extractor's method to compile.
@@ -18,17 +17,17 @@ export type SignedPattern = {
18
17
  *
19
18
  * @see {@link signedPatternIgnores} provides the ignoring algorithm.
20
19
  *
21
- * @since 0.6.0
20
+ * @since 0.9.0
22
21
  */
23
- include: Pattern;
22
+ pattern: Pattern;
24
23
  /**
25
- * Provides ignored or included file and directory patterns.
24
+ * If `true`, pattern "test" will exclude file named "test".
26
25
  *
27
26
  * @see {@link signedPatternIgnores} provides the ignoring algorithm.
28
27
  *
29
- * @since 0.6.0
28
+ * @since 0.9.0
30
29
  */
31
- exclude: Pattern;
30
+ excludes: boolean;
32
31
  /**
33
32
  * Provides compiled ignored or included file and directory patterns.
34
33
  *
@@ -36,52 +35,60 @@ export type SignedPattern = {
36
35
  *
37
36
  * @since 0.6.0
38
37
  */
39
- compiled: null | {
40
- /**
41
- * Provides compiled ignored or included file and directory patterns.
42
- *
43
- * @see {@link signedPatternIgnores} provides the ignoring algorithm.
44
- *
45
- * @since 0.6.0
46
- */
47
- include: PatternMinimatch[];
48
- /**
49
- * Provides compiled ignored or included file and directory patterns.
50
- *
51
- * @see {@link signedPatternIgnores} provides the ignoring algorithm.
52
- *
53
- * @since 0.6.0
54
- */
55
- exclude: PatternMinimatch[];
56
- };
38
+ compiled: null | PatternMinimatch[];
57
39
  };
58
40
  /**
59
- * @see {@link signedPatternIgnores}
41
+ * The kind of a pattern match.
60
42
  *
61
- * @since 0.6.0
43
+ * @since 0.9.1
62
44
  */
63
- export type SignedPatternMatch = {
64
- kind: "none" | "missing-source";
65
- ignored: boolean;
66
- } | {
67
- kind: "no-match" | "broken-source" | "invalid-pattern";
45
+ export type MatchKind = SignedPatternMatch["kind"];
46
+ /**
47
+ * @see {@link SignedPatternMatch}
48
+ *
49
+ * @since 0.9.1
50
+ */
51
+ export interface MatchBase<K extends string> {
52
+ kind: K;
68
53
  ignored: boolean;
54
+ }
55
+ /**
56
+ * @see {@link SignedPatternMatch}
57
+ *
58
+ * @since 0.9.1
59
+ */
60
+ export interface MatchBaseSource<K extends string> extends MatchBase<K> {
69
61
  source: Source;
70
- } | {
71
- kind: "invalid-internal-pattern";
62
+ }
63
+ /**
64
+ * @see {@link SignedPatternMatch}
65
+ *
66
+ * @since 0.9.1
67
+ */
68
+ export interface MatchBasePattern<K extends string> extends MatchBase<K> {
72
69
  pattern: string;
70
+ }
71
+ /**
72
+ * @see {@link SignedPatternMatch}
73
+ *
74
+ * @since 0.9.1
75
+ */
76
+ export interface MatchBaseErrorPattern<K extends string> extends MatchBasePattern<K> {
73
77
  error: Error;
74
- ignored: boolean;
75
- } | {
76
- kind: "internal";
77
- pattern: string;
78
- ignored: boolean;
79
- } | {
80
- kind: "external";
81
- pattern: string;
82
- source: Source;
83
- ignored: boolean;
84
- };
78
+ }
79
+ /**
80
+ * @see {@link SignedPatternMatch}
81
+ *
82
+ * @since 0.9.1
83
+ */
84
+ export interface MatchBaseSourcePattern<K extends string> extends MatchBasePattern<K>, MatchBaseSource<K> {
85
+ }
86
+ /**
87
+ * @see {@link signedPatternIgnores}
88
+ *
89
+ * @since 0.6.0
90
+ */
91
+ export type SignedPatternMatch = MatchBase<"none" | "missing-source"> | MatchBaseSource<"no-match" | "broken-source" | "invalid-pattern"> | MatchBaseErrorPattern<"invalid-internal-pattern"> | MatchBasePattern<"internal"> | MatchBaseSourcePattern<"external">;
85
92
  /**
86
93
  * @see {@link signedPatternIgnores}
87
94
  *
@@ -103,24 +110,12 @@ export interface SignedPatternIgnoresOptions extends PatternFinderOptions {
103
110
  *
104
111
  * @since 0.6.0
105
112
  */
106
- internal: SignedPattern;
113
+ internal: SignedPattern[];
107
114
  }
108
115
  /**
109
116
  * Checks whether a given entry should be ignored based on internal and external patterns.
110
117
  * Populates unknown sources using {@link resolveSources}.
111
118
  *
112
- * Algorithm:
113
- * 1. Check internal exclude patterns. If matched, return true.
114
- * 2. Check internal include patterns. If matched, return false.
115
- * 3. Check external patterns:
116
- * - If not inverted:
117
- * a. Check external include patterns. If matched, return false.
118
- * b. Check external exclude patterns. If matched, return true.
119
- * - If inverted:
120
- * a. Check external exclude patterns. If matched, return true.
121
- * b. Check external include patterns. If matched, return false.
122
- * 4. If no patterns matched, return the inverted state.
123
- *
124
119
  * @since 0.6.0
125
120
  */
126
121
  export declare function signedPatternIgnores(options: SignedPatternIgnoresOptions): Promise<SignedPatternMatch>;
@@ -15,112 +15,61 @@ function patternRegExpTest(path, rs) {
15
15
  return ["", undefined];
16
16
  }
17
17
  function signedPatternCompiledMatchInternal(options, path) {
18
- let patternMatch = "";
19
- let err;
20
- const kind = "internal";
21
- const signedPattern = options.internal;
22
- const compiled = signedPattern.compiled; // no null
23
- try {
24
- ;
25
- [patternMatch, err] = patternRegExpTest(path, compiled.exclude);
26
- if (err) {
27
- throw err;
28
- }
29
- if (patternMatch) {
30
- // return true
31
- return { kind, pattern: patternMatch, ignored: true };
32
- }
33
- ;
34
- [patternMatch, err] = patternRegExpTest(path, compiled.include);
35
- if (err) {
36
- throw err;
37
- }
38
- if (patternMatch) {
39
- // return false
40
- return { kind, pattern: patternMatch, ignored: false };
41
- }
42
- }
43
- catch (error) {
44
- return {
45
- kind: "invalid-internal-pattern",
46
- pattern: patternMatch,
47
- error: error,
48
- ignored: false,
49
- };
18
+ for (const si of options.internal) {
19
+ const compiled = si.compiled;
20
+ if (compiled === null)
21
+ continue;
22
+ let [patternMatch, error] = patternRegExpTest(path, compiled);
23
+ if (error)
24
+ return {
25
+ kind: "invalid-internal-pattern",
26
+ pattern: patternMatch,
27
+ error,
28
+ ignored: false,
29
+ };
30
+ if (patternMatch)
31
+ return {
32
+ kind: "internal",
33
+ pattern: patternMatch,
34
+ ignored: si.excludes,
35
+ };
50
36
  }
51
37
  return null;
52
38
  }
53
39
  function signedPatternCompiledMatchExternal(options, path, source) {
54
- let patternMatch = "";
55
- let err;
56
- const kind = "external";
57
- const signedPattern = source.pattern;
58
- const compiled = signedPattern.compiled; // no null
59
- try {
60
- if (source.inverted) {
61
- ;
62
- [patternMatch, err] = patternRegExpTest(path, compiled.exclude);
63
- if (err) {
64
- throw err;
65
- }
66
- if (patternMatch) {
67
- // return true
68
- return { kind, source, pattern: patternMatch, ignored: true };
69
- }
70
- ;
71
- [patternMatch, err] = patternRegExpTest(path, compiled.include);
72
- if (err) {
73
- throw err;
74
- }
75
- if (patternMatch) {
76
- // return false
77
- return { kind, source, pattern: patternMatch, ignored: false };
78
- }
40
+ for (const si of source.pattern) {
41
+ const compiled = si.compiled;
42
+ if (compiled === null) {
43
+ continue;
79
44
  }
80
- else {
81
- ;
82
- [patternMatch, err] = patternRegExpTest(path, compiled.include);
83
- if (err) {
84
- throw err;
85
- }
86
- if (patternMatch) {
87
- // return false
88
- return { kind, source, pattern: patternMatch, ignored: false };
89
- }
90
- ;
91
- [patternMatch, err] = patternRegExpTest(path, compiled.exclude);
92
- if (err) {
93
- throw err;
94
- }
95
- if (patternMatch) {
96
- // return true
97
- return { kind, source, pattern: patternMatch, ignored: true };
98
- }
45
+ let [patternMatch, err] = patternRegExpTest(path, compiled);
46
+ if (err) {
47
+ source.error = err;
48
+ options.ctx?.failed.push(source);
49
+ return {
50
+ kind: "invalid-pattern",
51
+ ignored: false,
52
+ source,
53
+ };
99
54
  }
55
+ if (patternMatch)
56
+ return {
57
+ kind: "external",
58
+ pattern: patternMatch,
59
+ ignored: si.excludes,
60
+ source,
61
+ };
100
62
  }
101
- catch (err) {
102
- source.error = err;
103
- options.ctx?.failed.push(source);
104
- return { kind: "invalid-pattern", ignored: false, source };
105
- }
106
- return { kind: "no-match", ignored: source.inverted, source };
63
+ return {
64
+ kind: "no-match",
65
+ ignored: source.inverted,
66
+ source,
67
+ };
107
68
  }
108
69
  /**
109
70
  * Checks whether a given entry should be ignored based on internal and external patterns.
110
71
  * Populates unknown sources using {@link resolveSources}.
111
72
  *
112
- * Algorithm:
113
- * 1. Check internal exclude patterns. If matched, return true.
114
- * 2. Check internal include patterns. If matched, return false.
115
- * 3. Check external patterns:
116
- * - If not inverted:
117
- * a. Check external include patterns. If matched, return false.
118
- * b. Check external exclude patterns. If matched, return true.
119
- * - If inverted:
120
- * a. Check external exclude patterns. If matched, return true.
121
- * b. Check external include patterns. If matched, return false.
122
- * 4. If no patterns matched, return the inverted state.
123
- *
124
73
  * @since 0.6.0
125
74
  */
126
75
  export async function signedPatternIgnores(options) {
@@ -131,7 +80,7 @@ export async function signedPatternIgnores(options) {
131
80
  source = options.ctx.external.get(parent);
132
81
  }
133
82
  if (source === undefined || source === "none") {
134
- return { kind: "missing-source", ignored: true };
83
+ return { kind: "missing-source", ignored: false };
135
84
  }
136
85
  if (typeof source === "object" && source.error) {
137
86
  return { kind: "broken-source", ignored: true, source };
@@ -9,12 +9,11 @@ export type Source = {
9
9
  * Patterns defined within the source file.
10
10
  * Those patterns are for ignoring files.
11
11
  *
12
- * @see {@link PatternMatcher}
13
12
  * @see {@link signedPatternIgnores}
14
13
  *
15
14
  * @since 0.6.0
16
15
  */
17
- pattern: SignedPattern;
16
+ pattern: SignedPattern[];
18
17
  /**
19
18
  * Name of the source file.
20
19
  *
@@ -32,7 +31,6 @@ export type Source = {
32
31
  * For example, `package.json` `files` field inverts the matching logic,
33
32
  * because it specifies files to include rather than exclude.
34
33
  *
35
- * @see {@link PatternMatcher}
36
34
  * @see {@link signedPatternIgnores}
37
35
  *
38
36
  * @since 0.6.0
@@ -54,4 +52,4 @@ export type Source = {
54
52
  *
55
53
  * @since 0.6.0
56
54
  */
57
- export declare function sourcePushNegatable(source: Source, pattern: string): void;
55
+ export declare function sourcePushNegatable(pattern: string, invert: boolean, include: SignedPattern, exclude: SignedPattern): void;
@@ -5,9 +5,8 @@
5
5
  *
6
6
  * @since 0.6.0
7
7
  */
8
- export function sourcePushNegatable(source, pattern) {
9
- let exclude = source.pattern.exclude, include = source.pattern.include;
10
- if (source.inverted) {
8
+ export function sourcePushNegatable(pattern, invert, include, exclude) {
9
+ if (invert) {
11
10
  ;
12
11
  [exclude, include] = [include, exclude];
13
12
  }
@@ -16,5 +15,5 @@ export function sourcePushNegatable(source, pattern) {
16
15
  dist = include;
17
16
  pattern = pattern.substring(1);
18
17
  }
19
- dist.push(pattern);
18
+ dist.pattern.push(pattern);
20
19
  }