repomeld 3.0.1 → 3.0.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/package.json +1 -1
- package/src/core/fileScanner.js +41 -10
package/package.json
CHANGED
package/src/core/fileScanner.js
CHANGED
|
@@ -2,10 +2,20 @@ const fs = require("fs").promises;
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const { normalizePath } = require("../utils/constants");
|
|
4
4
|
|
|
5
|
+
// Pattern to detect repomeld-related files/folders
|
|
6
|
+
const REPOMELD_PATTERN = /^repomeld/i; // Case-insensitive, matches anything starting with "repomeld"
|
|
7
|
+
|
|
5
8
|
async function getAllFilesWithIgnore(dirPath, ig, forceIncludePatterns) {
|
|
6
9
|
const fileList = [];
|
|
7
10
|
const stack = [{ dirPath, relativePath: '.' }];
|
|
8
11
|
|
|
12
|
+
// Pre-process force include patterns for faster matching
|
|
13
|
+
const processedPatterns = forceIncludePatterns?.map(pattern => ({
|
|
14
|
+
original: pattern,
|
|
15
|
+
clean: pattern.replace(/^\.\//, '').replace(/\/$/, ''),
|
|
16
|
+
isExact: !pattern.includes('*') && !pattern.includes('/')
|
|
17
|
+
})) || [];
|
|
18
|
+
|
|
9
19
|
while (stack.length) {
|
|
10
20
|
const { dirPath: currentDir, relativePath: currentRelative } = stack.pop();
|
|
11
21
|
|
|
@@ -20,19 +30,40 @@ async function getAllFilesWithIgnore(dirPath, ig, forceIncludePatterns) {
|
|
|
20
30
|
const fullPath = path.join(currentDir, entry.name);
|
|
21
31
|
const relativePath = path.join(currentRelative, entry.name);
|
|
22
32
|
const normalizedPath = normalizePath(relativePath);
|
|
33
|
+
|
|
34
|
+
// HARD-CODED: Always ignore any file/folder starting with "repomeld"
|
|
35
|
+
// This prevents recursive inclusion and infinite loops
|
|
36
|
+
// Also ignores repomeld_output.txt, repomeld_zips/, etc.
|
|
37
|
+
if (REPOMELD_PATTERN.test(entry.name)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
23
40
|
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
// Fast force-include check
|
|
42
|
+
let isForceIncluded = false;
|
|
43
|
+
if (processedPatterns.length) {
|
|
44
|
+
for (const pattern of processedPatterns) {
|
|
45
|
+
if (pattern.isExact) {
|
|
46
|
+
// Exact match - fastest
|
|
47
|
+
if (entry.name === pattern.clean || normalizedPath === pattern.clean) {
|
|
48
|
+
isForceIncluded = true;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
// Pattern matching
|
|
53
|
+
if (normalizedPath.includes(pattern.clean) ||
|
|
54
|
+
normalizedPath.startsWith(pattern.clean + '/') ||
|
|
55
|
+
entry.name.includes(pattern.clean)) {
|
|
56
|
+
isForceIncluded = true;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
33
62
|
|
|
34
63
|
// Only check ignore if not force-included
|
|
35
|
-
if (!isForceIncluded && ig.ignores(normalizedPath))
|
|
64
|
+
if (!isForceIncluded && ig.ignores(normalizedPath)) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
36
67
|
|
|
37
68
|
if (entry.isDirectory()) {
|
|
38
69
|
stack.push({ dirPath: fullPath, relativePath });
|