@mintlify/common 1.0.1345 → 1.0.1346
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.js
CHANGED
|
@@ -86,7 +86,37 @@ export function isMintIgnoredBy(filePath, matcher, isDirectory = false) {
|
|
|
86
86
|
* @returns A matcher covering DEFAULT_MINT_IGNORES plus the provided patterns.
|
|
87
87
|
*/
|
|
88
88
|
export function createMintIgnoreMatcher(globs = []) {
|
|
89
|
-
|
|
89
|
+
if (globs.some((glob) => glob.startsWith('!') || /[\r\n]/.test(glob))) {
|
|
90
|
+
return ignore().add(Array.from(new Set([...DEFAULT_MINT_IGNORES, ...globs])));
|
|
91
|
+
}
|
|
92
|
+
const literalPaths = new Set();
|
|
93
|
+
const patterns = globs.filter((glob) => {
|
|
94
|
+
const relative = glob.replace(/^\//, '');
|
|
95
|
+
if ((!glob.startsWith('/') && !relative.replace(/\/$/, '').includes('/')) ||
|
|
96
|
+
!/^[a-zA-Z0-9_.-]+(?:\/[a-zA-Z0-9_.-]+)*\/?$/.test(relative) ||
|
|
97
|
+
relative.split('/').some((segment) => segment === '.' || segment === '..')) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
literalPaths.add(relative.toLowerCase());
|
|
101
|
+
return false;
|
|
102
|
+
});
|
|
103
|
+
const matcher = ignore().add(Array.from(new Set([...DEFAULT_MINT_IGNORES, ...patterns])));
|
|
104
|
+
if (literalPaths.size === 0)
|
|
105
|
+
return matcher;
|
|
106
|
+
return {
|
|
107
|
+
ignores(filePath) {
|
|
108
|
+
if (matcher.ignores(filePath))
|
|
109
|
+
return true;
|
|
110
|
+
const lowerPath = filePath.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
|
|
111
|
+
for (let end = lowerPath.indexOf('/'); end !== -1; end = lowerPath.indexOf('/', end + 1)) {
|
|
112
|
+
if (literalPaths.has(lowerPath.slice(0, end)) ||
|
|
113
|
+
literalPaths.has(lowerPath.slice(0, end + 1))) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return literalPaths.has(lowerPath);
|
|
118
|
+
},
|
|
119
|
+
};
|
|
90
120
|
}
|
|
91
121
|
function normalizeMintIgnorePath(filePath) {
|
|
92
122
|
let normalized = toPosixPath(filePath);
|