view-ignored 0.5.1 → 0.5.2
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/patterns/gitignore.d.ts +1 -1
- package/out/patterns/gitignore.js +2 -6
- package/out/patterns/matcher.d.ts +13 -1
- package/out/patterns/matcher.js +12 -0
- package/out/patterns/packagejson.d.ts +1 -1
- package/out/patterns/packagejson.js +3 -7
- package/out/scan.js +5 -6
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sourcePushNegatable } from './matcher.js';
|
|
1
2
|
import { minimatch } from 'minimatch';
|
|
2
3
|
export function extractGitignore(source, content) {
|
|
3
4
|
for (let line of content.toString().split('\n')) {
|
|
@@ -9,12 +10,7 @@ export function extractGitignore(source, content) {
|
|
|
9
10
|
if (cdx >= 0) {
|
|
10
11
|
line = line.substring(-cdx);
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
source.pattern.include.push(line.substring(1));
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
source.pattern.exclude.push(line);
|
|
17
|
-
}
|
|
13
|
+
sourcePushNegatable(source, line);
|
|
18
14
|
}
|
|
19
15
|
// TODO: validate gitignore
|
|
20
16
|
}
|
|
@@ -46,6 +46,8 @@ export declare function patternMatches(pattern: Pattern, path: string): boolean;
|
|
|
46
46
|
/**
|
|
47
47
|
* Represents a set of include and exclude patterns.
|
|
48
48
|
* These patterns are positive minimatch patterns.
|
|
49
|
+
*
|
|
50
|
+
* @see {@link PatternMatcher}
|
|
49
51
|
*/
|
|
50
52
|
export type SignedPattern = {
|
|
51
53
|
include: Pattern;
|
|
@@ -53,7 +55,11 @@ export type SignedPattern = {
|
|
|
53
55
|
};
|
|
54
56
|
/**
|
|
55
57
|
* Combined internal and external patterns for matching.
|
|
56
|
-
*
|
|
58
|
+
*
|
|
59
|
+
* `exclude` patterns take precedence over `include` patterns.
|
|
60
|
+
*
|
|
61
|
+
* `internal` patterns take precedence over `external` patterns.
|
|
62
|
+
* @see {@link signedPatternIgnores}
|
|
57
63
|
*/
|
|
58
64
|
export type PatternMatcher = {
|
|
59
65
|
internal: SignedPattern;
|
|
@@ -86,6 +92,12 @@ export type Source = {
|
|
|
86
92
|
*/
|
|
87
93
|
inverted: boolean;
|
|
88
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Adds a negatable pattern to the source's pattern lists.
|
|
97
|
+
* Strips the leading '!' for include patterns,
|
|
98
|
+
* and adds to exclude patterns otherwise.
|
|
99
|
+
*/
|
|
100
|
+
export declare function sourcePushNegatable(source: Source, pattern: string): void;
|
|
89
101
|
/**
|
|
90
102
|
* Populates a `Source` object from the content of a source file.
|
|
91
103
|
* @see {@link Source.pattern} for more details.
|
package/out/patterns/matcher.js
CHANGED
|
@@ -10,6 +10,18 @@ export function patternMatches(pattern, path) {
|
|
|
10
10
|
}
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Adds a negatable pattern to the source's pattern lists.
|
|
15
|
+
* Strips the leading '!' for include patterns,
|
|
16
|
+
* and adds to exclude patterns otherwise.
|
|
17
|
+
*/
|
|
18
|
+
export function sourcePushNegatable(source, pattern) {
|
|
19
|
+
if (pattern.startsWith('!')) {
|
|
20
|
+
source.pattern.include.push(pattern.substring(1));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
source.pattern.exclude.push(pattern);
|
|
24
|
+
}
|
|
13
25
|
/**
|
|
14
26
|
* Populates the {@link MatcherContext.external} map with {@link Source} objects.
|
|
15
27
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type } from 'arktype';
|
|
2
|
+
import { sourcePushNegatable, } from './matcher.js';
|
|
2
3
|
const nodeJsManifest = type({
|
|
3
4
|
files: 'string[]?',
|
|
4
5
|
});
|
|
@@ -12,13 +13,8 @@ export function extractPackageJson(source, content) {
|
|
|
12
13
|
if (!dist.files) {
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
15
|
-
for (const
|
|
16
|
-
|
|
17
|
-
source.pattern.exclude.push(...p.substring(1));
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
source.pattern.include.push(...p);
|
|
21
|
-
}
|
|
16
|
+
for (const pattern of dist.files) {
|
|
17
|
+
sourcePushNegatable(source, pattern);
|
|
22
18
|
}
|
|
23
19
|
return;
|
|
24
20
|
}
|
package/out/scan.js
CHANGED
|
@@ -13,6 +13,9 @@ import { opendir } from './walk.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export async function scan(options) {
|
|
15
15
|
const { target, cwd: cwdo = (await import('node:process')).cwd(), depth: maxDepth = Infinity, invert = false, signal = undefined, fastDepth = false, } = options;
|
|
16
|
+
if (maxDepth < 0) {
|
|
17
|
+
throw new TypeError('Depth must be a non-negative integer');
|
|
18
|
+
}
|
|
16
19
|
const cwd = cwdo.replaceAll('\\', '/');
|
|
17
20
|
const ctx = {
|
|
18
21
|
paths: new Set(),
|
|
@@ -24,9 +27,7 @@ export async function scan(options) {
|
|
|
24
27
|
totalDirs: 0,
|
|
25
28
|
};
|
|
26
29
|
await opendir(cwd, async (entry) => {
|
|
27
|
-
|
|
28
|
-
return 2;
|
|
29
|
-
}
|
|
30
|
+
signal?.throwIfAborted();
|
|
30
31
|
const path = posix.join(posix.relative(cwd, entry.parentPath.replaceAll('\\', '/')), entry.name);
|
|
31
32
|
if (entry.isDirectory()) {
|
|
32
33
|
ctx.totalDirs++;
|
|
@@ -79,9 +80,7 @@ export async function scan(options) {
|
|
|
79
80
|
}
|
|
80
81
|
return 0;
|
|
81
82
|
});
|
|
82
|
-
|
|
83
|
-
return ctx;
|
|
84
|
-
}
|
|
83
|
+
signal?.throwIfAborted();
|
|
85
84
|
for (const [dir, count] of ctx.depthPaths) {
|
|
86
85
|
if (count === 0) {
|
|
87
86
|
continue;
|