print-project
Advanced tools
Comparing version 1.0.28 to 1.0.29
@@ -87,7 +87,9 @@ #!/usr/bin/env node | ||
if (entry.isDirectory()) { | ||
if (shouldProcess(relativePath)) { | ||
// Don't use shouldProcess() for directories when includes are specified. | ||
// Only skip directories if they match an ignore pattern. | ||
if (!matchesAnyPattern(relativePath, ignorePatterns)) { | ||
const subTree = {}; | ||
treeStructure[relativePath] = subTree; | ||
readDirectory(fullPath, subTree); | ||
// Remove empty directories | ||
// Remove empty directories if no included files end up inside | ||
if (Object.keys(subTree).length === 0) { | ||
@@ -98,13 +100,16 @@ delete treeStructure[relativePath]; | ||
} | ||
else if (entry.isFile() && shouldProcess(relativePath)) { | ||
try { | ||
const content = fs.readFileSync(fullPath, "utf8"); | ||
if (content.length > 0) { | ||
treeStructure[relativePath] = {}; | ||
projectPrint += `${relativePath}:\n${content}\n\n`; | ||
else if (entry.isFile()) { | ||
// For files, apply the include and ignore logic | ||
if (shouldProcess(relativePath)) { | ||
try { | ||
const content = fs.readFileSync(fullPath, "utf8"); | ||
if (content.length > 0) { | ||
treeStructure[relativePath] = {}; | ||
projectPrint += `${relativePath}:\n${content}\n\n`; | ||
} | ||
} | ||
catch (error) { | ||
console.error(`Error reading file ${relativePath}:`, error.message); | ||
} | ||
} | ||
catch (error) { | ||
console.error(`Error reading file ${relativePath}:`, error.message); | ||
} | ||
} | ||
@@ -111,0 +116,0 @@ } |
{ | ||
"name": "print-project", | ||
"version": "1.0.28", | ||
"version": "1.0.29", | ||
"description": "A simple CLI tool to print the project tree structure and file contents", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -182,3 +182,3 @@ File structure: | ||
"name": "print-project", | ||
"version": "1.0.27", | ||
"version": "1.0.28", | ||
"description": "A simple CLI tool to print the project tree structure and file contents", | ||
@@ -188,3 +188,4 @@ "main": "dist/index.js", | ||
"print-project": "./dist/index.js", | ||
"pprint": "./dist/index.js" | ||
"pprint": "./dist/index.js", | ||
"pp": "./dist/index.js" | ||
}, | ||
@@ -191,0 +192,0 @@ "types": "dist/index.d.ts", |
@@ -77,3 +77,5 @@ #!/usr/bin/env node | ||
if (entry.isDirectory()) { | ||
if (shouldProcess(relativePath)) { | ||
// Don't use shouldProcess() for directories when includes are specified. | ||
// Only skip directories if they match an ignore pattern. | ||
if (!matchesAnyPattern(relativePath, ignorePatterns)) { | ||
const subTree = {}; | ||
@@ -83,3 +85,3 @@ treeStructure[relativePath] = subTree; | ||
// Remove empty directories | ||
// Remove empty directories if no included files end up inside | ||
if (Object.keys(subTree).length === 0) { | ||
@@ -89,11 +91,14 @@ delete treeStructure[relativePath]; | ||
} | ||
} else if (entry.isFile() && shouldProcess(relativePath)) { | ||
try { | ||
const content = fs.readFileSync(fullPath, "utf8"); | ||
if (content.length > 0) { | ||
treeStructure[relativePath] = {}; | ||
projectPrint += `${relativePath}:\n${content}\n\n`; | ||
} else if (entry.isFile()) { | ||
// For files, apply the include and ignore logic | ||
if (shouldProcess(relativePath)) { | ||
try { | ||
const content = fs.readFileSync(fullPath, "utf8"); | ||
if (content.length > 0) { | ||
treeStructure[relativePath] = {}; | ||
projectPrint += `${relativePath}:\n${content}\n\n`; | ||
} | ||
} catch (error: any) { | ||
console.error(`Error reading file ${relativePath}:`, error.message); | ||
} | ||
} catch (error: any) { | ||
console.error(`Error reading file ${relativePath}:`, error.message); | ||
} | ||
@@ -100,0 +105,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35670
499