make-folder-txt 1.2.0 → 1.3.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 +20 -0
- package/bin/make-folder-txt.js +38 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,6 +59,25 @@ make-folder-txt --ignore-folder examples extensions docs --ignore-file LICENSE
|
|
|
59
59
|
make-folder-txt --ignore-file .env .env.local secrets.txt
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
+
Use a `.txtignore` file (works like `.gitignore`):
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Create a .txtignore file in your project root
|
|
66
|
+
echo "node_modules/" > .txtignore
|
|
67
|
+
echo "*.log" >> .txtignore
|
|
68
|
+
echo ".env" >> .txtignore
|
|
69
|
+
echo "coverage/" >> .txtignore
|
|
70
|
+
|
|
71
|
+
# The tool will automatically read and respect .txtignore patterns
|
|
72
|
+
make-folder-txt
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The `.txtignore` file supports:
|
|
76
|
+
- File and folder names (one per line)
|
|
77
|
+
- Wildcard patterns (`*.log`, `temp-*`)
|
|
78
|
+
- Comments (lines starting with `#`)
|
|
79
|
+
- Folder patterns with trailing slash (`docs/`)
|
|
80
|
+
|
|
62
81
|
Include only specific folders/files by name (everything else is ignored):
|
|
63
82
|
|
|
64
83
|
```bash
|
|
@@ -155,6 +174,7 @@ The tool is smart about what it ignores so your output stays clean and readable.
|
|
|
155
174
|
| 📏 Large files | Any file over **500 KB** |
|
|
156
175
|
| 🗑️ System files | `.DS_Store`, `Thumbs.db`, `desktop.ini` |
|
|
157
176
|
| 📄 Output file | The generated `foldername.txt` file (to avoid infinite loops) |
|
|
177
|
+
| 📝 .txtignore | Any files/folders specified in `.txtignore` file |
|
|
158
178
|
|
|
159
179
|
Binary and skipped files are noted in the output as `[binary / skipped]` so you always know what was omitted.
|
|
160
180
|
|
package/bin/make-folder-txt.js
CHANGED
|
@@ -6,7 +6,7 @@ const { version } = require("../package.json");
|
|
|
6
6
|
|
|
7
7
|
// ── config ────────────────────────────────────────────────────────────────────
|
|
8
8
|
const IGNORE_DIRS = new Set(["node_modules", ".git", ".next", "dist", "build", ".cache"]);
|
|
9
|
-
const IGNORE_FILES = new Set([".DS_Store", "Thumbs.db", "desktop.ini"]);
|
|
9
|
+
const IGNORE_FILES = new Set([".DS_Store", "Thumbs.db", "desktop.ini", ".txtignore"]);
|
|
10
10
|
|
|
11
11
|
const BINARY_EXTS = new Set([
|
|
12
12
|
".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico", ".svg", ".webp",
|
|
@@ -19,6 +19,24 @@ const BINARY_EXTS = new Set([
|
|
|
19
19
|
|
|
20
20
|
// ── helpers ───────────────────────────────────────────────────────────────────
|
|
21
21
|
|
|
22
|
+
function readTxtIgnore(rootDir) {
|
|
23
|
+
const txtIgnorePath = path.join(rootDir, '.txtignore');
|
|
24
|
+
const ignorePatterns = new Set();
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const content = fs.readFileSync(txtIgnorePath, 'utf8');
|
|
28
|
+
const lines = content.split('\n')
|
|
29
|
+
.map(line => line.trim())
|
|
30
|
+
.filter(line => line && !line.startsWith('#'));
|
|
31
|
+
|
|
32
|
+
lines.forEach(line => ignorePatterns.add(line));
|
|
33
|
+
} catch (err) {
|
|
34
|
+
// .txtignore doesn't exist or can't be read - that's fine
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return ignorePatterns;
|
|
38
|
+
}
|
|
39
|
+
|
|
22
40
|
function collectFiles(
|
|
23
41
|
dir,
|
|
24
42
|
rootDir,
|
|
@@ -35,6 +53,7 @@ function collectFiles(
|
|
|
35
53
|
inSelectedFolder = false,
|
|
36
54
|
hasOnlyFilters = false,
|
|
37
55
|
rootName = "",
|
|
56
|
+
txtIgnore = new Set(),
|
|
38
57
|
} = options;
|
|
39
58
|
|
|
40
59
|
let entries;
|
|
@@ -62,6 +81,14 @@ function collectFiles(
|
|
|
62
81
|
return;
|
|
63
82
|
}
|
|
64
83
|
|
|
84
|
+
// Check against .txtignore patterns
|
|
85
|
+
if (txtIgnore.has(entry.name) || txtIgnore.has(`${entry.name}/`)) {
|
|
86
|
+
if (!hasOnlyFilters) {
|
|
87
|
+
lines.push(`${indent}${connector}${entry.name}/ [skipped]`);
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
65
92
|
const childPath = path.join(dir, entry.name);
|
|
66
93
|
const childInSelectedFolder = inSelectedFolder || onlyFolders.has(entry.name);
|
|
67
94
|
const childLines = [];
|
|
@@ -80,6 +107,7 @@ function collectFiles(
|
|
|
80
107
|
inSelectedFolder: childInSelectedFolder,
|
|
81
108
|
hasOnlyFilters,
|
|
82
109
|
rootName,
|
|
110
|
+
txtIgnore,
|
|
83
111
|
},
|
|
84
112
|
);
|
|
85
113
|
|
|
@@ -94,6 +122,11 @@ function collectFiles(
|
|
|
94
122
|
} else {
|
|
95
123
|
if (ignoreFiles.has(entry.name)) return;
|
|
96
124
|
|
|
125
|
+
// Check against .txtignore patterns
|
|
126
|
+
if (txtIgnore.has(entry.name)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
97
130
|
// Ignore .txt files that match the folder name (e.g., foldername.txt)
|
|
98
131
|
if (entry.name.endsWith('.txt') && entry.name === `${rootName}.txt`) return;
|
|
99
132
|
|
|
@@ -255,6 +288,9 @@ for (let i = 0; i < args.length; i += 1) {
|
|
|
255
288
|
const folderPath = process.cwd();
|
|
256
289
|
const rootName = path.basename(folderPath);
|
|
257
290
|
|
|
291
|
+
// Read .txtignore file if it exists
|
|
292
|
+
const txtIgnore = readTxtIgnore(folderPath);
|
|
293
|
+
|
|
258
294
|
const outputFile = outputArg
|
|
259
295
|
? path.resolve(outputArg)
|
|
260
296
|
: path.join(process.cwd(), `${rootName}.txt`);
|
|
@@ -269,7 +305,7 @@ const { lines: treeLines, filePaths } = collectFiles(
|
|
|
269
305
|
ignoreFiles,
|
|
270
306
|
onlyFolders,
|
|
271
307
|
onlyFiles,
|
|
272
|
-
{ hasOnlyFilters, rootName },
|
|
308
|
+
{ hasOnlyFilters, rootName, txtIgnore },
|
|
273
309
|
);
|
|
274
310
|
|
|
275
311
|
// ── build output ──────────────────────────────────────────────────────────────
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "make-folder-txt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Generate a single .txt file containing the full folder structure and file contents of any project, ignoring node_modules and other junk.",
|
|
5
5
|
"main": "bin/make-folder-txt.js",
|
|
6
6
|
"bin": {
|