combicode 1.7.2 → 1.7.4

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.
Files changed (2) hide show
  1. package/index.js +45 -17
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -179,8 +179,12 @@ function generateFileTree(filesWithSize, root, skipContentSet = null) {
179
179
  parts.forEach((part, index) => {
180
180
  const isFile = index === parts.length - 1;
181
181
  if (isFile) {
182
- const shouldSkipContent = skipContentSet && skipContentSet.has(relativePath);
183
- currentLevel[part] = { size: formattedSize, skipContent: shouldSkipContent };
182
+ const shouldSkipContent =
183
+ skipContentSet && skipContentSet.has(relativePath);
184
+ currentLevel[part] = {
185
+ size: formattedSize,
186
+ skipContent: shouldSkipContent,
187
+ };
184
188
  } else {
185
189
  if (!currentLevel[part]) {
186
190
  currentLevel[part] = {};
@@ -261,7 +265,8 @@ async function main() {
261
265
  default: false,
262
266
  })
263
267
  .option("skip-content", {
264
- describe: "Comma-separated glob patterns for files to include in tree but omit content",
268
+ describe:
269
+ "Comma-separated glob patterns for files to include in tree but omit content",
265
270
  type: "string",
266
271
  })
267
272
  .version(version)
@@ -283,6 +288,30 @@ async function main() {
283
288
  rootIgnoreManager.add(argv.exclude.split(","));
284
289
  }
285
290
 
291
+ const gitModulesPath = path.join(projectRoot, ".gitmodules");
292
+ if (fs.existsSync(gitModulesPath)) {
293
+ try {
294
+ const content = fs.readFileSync(gitModulesPath, "utf8");
295
+ const lines = content.split(/\r?\n/);
296
+ const submodulePaths = [];
297
+
298
+ for (const line of lines) {
299
+ // Match lines like: path = libs/my-lib
300
+ const match = line.match(/^\s*path\s*=\s*(.+?)\s*$/);
301
+ if (match) {
302
+ submodulePaths.push(match[1]);
303
+ }
304
+ }
305
+
306
+ if (submodulePaths.length > 0) {
307
+ // Add identified submodule paths to the ignore manager
308
+ rootIgnoreManager.add(submodulePaths);
309
+ }
310
+ } catch {
311
+ // Fail silently if .gitmodules cannot be read
312
+ }
313
+ }
314
+
286
315
  // Create skip-content manager
287
316
  const skipContentManager = ignore();
288
317
  if (argv.skipContent) {
@@ -330,16 +359,13 @@ async function main() {
330
359
  }
331
360
 
332
361
  // Calculate total size of included files (excluding files with skipped content)
333
- const totalSizeBytes = includedFiles.reduce(
334
- (acc, file) => {
335
- // Don't count files with skipped content in the total size
336
- if (skipContentSet.has(file.relativePath)) {
337
- return acc;
338
- }
339
- return acc + file.size;
340
- },
341
- 0
342
- );
362
+ const totalSizeBytes = includedFiles.reduce((acc, file) => {
363
+ // Don't count files with skipped content in the total size
364
+ if (skipContentSet.has(file.relativePath)) {
365
+ return acc;
366
+ }
367
+ return acc + file.size;
368
+ }, 0);
343
369
 
344
370
  if (includedFiles.length === 0) {
345
371
  console.error(
@@ -388,11 +414,13 @@ async function main() {
388
414
  for (const fileObj of includedFiles) {
389
415
  const relativePath = fileObj.relativePath.replace(/\\/g, "/");
390
416
  const shouldSkipContent = skipContentSet.has(fileObj.relativePath);
391
-
417
+
392
418
  outputStream.write(`### **FILE:** \`${relativePath}\`\n`);
393
- outputStream.write("```\n");
419
+ outputStream.write("````\n");
394
420
  if (shouldSkipContent) {
395
- outputStream.write(`(Content omitted - file size: ${fileObj.formattedSize})`);
421
+ outputStream.write(
422
+ `(Content omitted - file size: ${fileObj.formattedSize})`
423
+ );
396
424
  totalLines += 1;
397
425
  } else {
398
426
  try {
@@ -403,7 +431,7 @@ async function main() {
403
431
  outputStream.write(`... (error reading file: ${e.message}) ...`);
404
432
  }
405
433
  }
406
- outputStream.write("\n```\n\n");
434
+ outputStream.write("\n````\n\n");
407
435
  totalLines += 4; // Headers/footers lines
408
436
  }
409
437
  outputStream.end();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "combicode",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "A CLI tool to combine a project's codebase into a single file for LLM context.",
5
5
  "main": "index.js",
6
6
  "bin": {