print-project
Advanced tools
Comparing version 1.0.21 to 1.0.22
@@ -42,10 +42,16 @@ #!/usr/bin/env node | ||
let ignorePatterns = ["project-print.txt"]; // Always ignore the output file | ||
// Add user's ignore patterns | ||
ignorePatterns = [...ignorePatterns, ...userIgnorePatterns]; | ||
// If NOT using --ignore-default, add default patterns | ||
// If NOT using --ignore-default, add default patterns FIRST | ||
if (!options.ignoreDefault) { | ||
ignorePatterns = [...ignorePatterns, ...constants_1.defaultIgnorePatterns]; | ||
ignorePatterns = [...constants_1.defaultIgnorePatterns, ...ignorePatterns]; | ||
} | ||
// Add user's ignore patterns LAST to give them precedence | ||
ignorePatterns = [...ignorePatterns, ...userIgnorePatterns]; | ||
function matchesAnyPattern(filePath, patterns) { | ||
if (patterns.length === 0) { | ||
return false; | ||
} | ||
return patterns.some(pattern => { | ||
if (!pattern) { | ||
return false; | ||
} | ||
const normalizedPath = filePath.replace(/\\/g, "/").toLowerCase(); | ||
@@ -69,8 +75,3 @@ const normalizedPattern = pattern.toLowerCase(); | ||
if (includePatterns.length > 0) { | ||
const isIncluded = matchesAnyPattern(filePath, includePatterns); | ||
if (!isIncluded) { | ||
return false; | ||
} | ||
// If file matches include pattern, include it regardless of ignore patterns | ||
return true; | ||
return matchesAnyPattern(filePath, includePatterns); | ||
} | ||
@@ -85,6 +86,5 @@ // If no include patterns, exclude if matches ignore patterns | ||
const fullPath = path.join(dirPath, entry.name); | ||
const relativePath = path.relative(process.cwd(), fullPath).replace(/\\/g, "/"); | ||
const relativePath = path.relative(startPath || ".", fullPath).replace(/\\/g, "/"); | ||
if (entry.isDirectory()) { | ||
// Always process directory if we have include patterns, otherwise check ignore patterns | ||
if (includePatterns.length > 0 || !matchesAnyPattern(relativePath, ignorePatterns)) { | ||
if (shouldProcess(relativePath)) { | ||
const subTree = {}; | ||
@@ -91,0 +91,0 @@ treeStructure[relativePath] = subTree; |
{ | ||
"name": "print-project", | ||
"version": "1.0.21", | ||
"version": "1.0.22", | ||
"description": "A simple CLI tool to print the project tree structure and file contents", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -22,12 +22,20 @@ #!/usr/bin/env node | ||
// Add user's ignore patterns | ||
ignorePatterns = [...ignorePatterns, ...userIgnorePatterns]; | ||
// If NOT using --ignore-default, add default patterns | ||
// If NOT using --ignore-default, add default patterns FIRST | ||
if (!options.ignoreDefault) { | ||
ignorePatterns = [...ignorePatterns, ...defaultIgnorePatterns]; | ||
ignorePatterns = [...defaultIgnorePatterns, ...ignorePatterns]; | ||
} | ||
// Add user's ignore patterns LAST to give them precedence | ||
ignorePatterns = [...ignorePatterns, ...userIgnorePatterns]; | ||
function matchesAnyPattern(filePath: string, patterns: string[]): boolean { | ||
if (patterns.length === 0) { | ||
return false; | ||
} | ||
return patterns.some(pattern => { | ||
if (!pattern) { | ||
return false; | ||
} | ||
const normalizedPath = filePath.replace(/\\/g, "/").toLowerCase(); | ||
@@ -53,8 +61,3 @@ const normalizedPattern = pattern.toLowerCase(); | ||
if (includePatterns.length > 0) { | ||
const isIncluded = matchesAnyPattern(filePath, includePatterns); | ||
if (!isIncluded) { | ||
return false; | ||
} | ||
// If file matches include pattern, include it regardless of ignore patterns | ||
return true; | ||
return matchesAnyPattern(filePath, includePatterns); | ||
} | ||
@@ -72,7 +75,6 @@ | ||
const fullPath = path.join(dirPath, entry.name); | ||
const relativePath = path.relative(process.cwd(), fullPath).replace(/\\/g, "/"); | ||
const relativePath = path.relative(startPath || ".", fullPath).replace(/\\/g, "/"); | ||
if (entry.isDirectory()) { | ||
// Always process directory if we have include patterns, otherwise check ignore patterns | ||
if (includePatterns.length > 0 || !matchesAnyPattern(relativePath, ignorePatterns)) { | ||
if (shouldProcess(relativePath)) { | ||
const subTree = {}; | ||
@@ -79,0 +81,0 @@ treeStructure[relativePath] = subTree; |
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
Mixed license
License(Experimental) Package contains multiple licenses.
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
43852621
20
522
1