@mintlify/common 1.0.1105 → 1.0.1107
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/dist/mintIgnore.d.ts +36 -0
- package/dist/mintIgnore.js +33 -3
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/mintIgnore.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Ignore } from 'ignore';
|
|
1
2
|
/**
|
|
2
3
|
* Default patterns that Mintlify always ignores, regardless of .mintignore configuration.
|
|
3
4
|
* These directories are typically version control, IDE configs, or dependencies.
|
|
@@ -15,8 +16,43 @@ export declare function processMintIgnoreString(mintIgnoreContent: string): stri
|
|
|
15
16
|
* Checks if a file path is ignored based on the provided glob patterns and default ignores.
|
|
16
17
|
* Always includes DEFAULT_MINT_IGNORES in addition to any custom patterns provided.
|
|
17
18
|
*
|
|
19
|
+
* Compiles the patterns on every call, so this is for one-off checks only. To check
|
|
20
|
+
* many paths, build a matcher once with {@link createMintIgnoreMatcher} and pass it
|
|
21
|
+
* to {@link isMintIgnoredBy}.
|
|
22
|
+
*
|
|
18
23
|
* @param filePath The path of the file to check.
|
|
19
24
|
* @param globs An array of custom glob patterns (output from processMintIgnoreString).
|
|
20
25
|
* @returns True if the file matches any of the ignore patterns (default or custom), false otherwise.
|
|
21
26
|
*/
|
|
22
27
|
export declare function isMintIgnored(filePath: string, globs?: string[]): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* A reusable matcher produced by {@link createMintIgnoreMatcher}.
|
|
30
|
+
*
|
|
31
|
+
* Structural rather than the `ignore` package's own type, so callers can hold a
|
|
32
|
+
* matcher without taking a dependency on that package's typings.
|
|
33
|
+
*/
|
|
34
|
+
export type MintIgnoreMatcher = Pick<Ignore, 'ignores'>;
|
|
35
|
+
/**
|
|
36
|
+
* Checks a path against a matcher the caller already built.
|
|
37
|
+
*
|
|
38
|
+
* Prefer this over {@link isMintIgnored} in loops. Building the matcher is the
|
|
39
|
+
* expensive half of the check, so hoisting it out of the loop with
|
|
40
|
+
* {@link createMintIgnoreMatcher} makes that cost visible and pays it once.
|
|
41
|
+
*
|
|
42
|
+
* @param filePath The path of the file to check.
|
|
43
|
+
* @param matcher A matcher from {@link createMintIgnoreMatcher}.
|
|
44
|
+
* @returns True if the file matches any of the matcher's patterns, false otherwise.
|
|
45
|
+
*/
|
|
46
|
+
export declare function isMintIgnoredBy(filePath: string, matcher: MintIgnoreMatcher): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Compiles the default ignores plus any custom patterns into a reusable matcher.
|
|
49
|
+
*
|
|
50
|
+
* Compiling is orders of magnitude more expensive than testing a single path
|
|
51
|
+
* against the result, so anything checking more than a handful of paths should
|
|
52
|
+
* build one matcher here and pass it to {@link isMintIgnoredBy} rather than
|
|
53
|
+
* calling {@link isMintIgnored} per path.
|
|
54
|
+
*
|
|
55
|
+
* @param globs An array of custom glob patterns (output from processMintIgnoreString).
|
|
56
|
+
* @returns A matcher covering DEFAULT_MINT_IGNORES plus the provided patterns.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createMintIgnoreMatcher(globs?: string[]): MintIgnoreMatcher;
|
package/dist/mintIgnore.js
CHANGED
|
@@ -35,12 +35,42 @@ export function processMintIgnoreString(mintIgnoreContent) {
|
|
|
35
35
|
* Checks if a file path is ignored based on the provided glob patterns and default ignores.
|
|
36
36
|
* Always includes DEFAULT_MINT_IGNORES in addition to any custom patterns provided.
|
|
37
37
|
*
|
|
38
|
+
* Compiles the patterns on every call, so this is for one-off checks only. To check
|
|
39
|
+
* many paths, build a matcher once with {@link createMintIgnoreMatcher} and pass it
|
|
40
|
+
* to {@link isMintIgnoredBy}.
|
|
41
|
+
*
|
|
38
42
|
* @param filePath The path of the file to check.
|
|
39
43
|
* @param globs An array of custom glob patterns (output from processMintIgnoreString).
|
|
40
44
|
* @returns True if the file matches any of the ignore patterns (default or custom), false otherwise.
|
|
41
45
|
*/
|
|
42
46
|
export function isMintIgnored(filePath, globs = []) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
return isMintIgnoredBy(filePath, createMintIgnoreMatcher(globs));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Checks a path against a matcher the caller already built.
|
|
51
|
+
*
|
|
52
|
+
* Prefer this over {@link isMintIgnored} in loops. Building the matcher is the
|
|
53
|
+
* expensive half of the check, so hoisting it out of the loop with
|
|
54
|
+
* {@link createMintIgnoreMatcher} makes that cost visible and pays it once.
|
|
55
|
+
*
|
|
56
|
+
* @param filePath The path of the file to check.
|
|
57
|
+
* @param matcher A matcher from {@link createMintIgnoreMatcher}.
|
|
58
|
+
* @returns True if the file matches any of the matcher's patterns, false otherwise.
|
|
59
|
+
*/
|
|
60
|
+
export function isMintIgnoredBy(filePath, matcher) {
|
|
61
|
+
return matcher.ignores(filePath);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Compiles the default ignores plus any custom patterns into a reusable matcher.
|
|
65
|
+
*
|
|
66
|
+
* Compiling is orders of magnitude more expensive than testing a single path
|
|
67
|
+
* against the result, so anything checking more than a handful of paths should
|
|
68
|
+
* build one matcher here and pass it to {@link isMintIgnoredBy} rather than
|
|
69
|
+
* calling {@link isMintIgnored} per path.
|
|
70
|
+
*
|
|
71
|
+
* @param globs An array of custom glob patterns (output from processMintIgnoreString).
|
|
72
|
+
* @returns A matcher covering DEFAULT_MINT_IGNORES plus the provided patterns.
|
|
73
|
+
*/
|
|
74
|
+
export function createMintIgnoreMatcher(globs = []) {
|
|
75
|
+
return ignore().add(Array.from(new Set([...DEFAULT_MINT_IGNORES, ...globs])));
|
|
46
76
|
}
|