print-project
Advanced tools
Comparing version 1.0.14 to 1.0.15
@@ -35,8 +35,3 @@ #!/usr/bin/env node | ||
const program = new commander_1.Command(); | ||
program | ||
.argument("<startPath>", "Starting directory path") | ||
.option("--ignore <patterns>", "Comma-separated list of patterns to ignore") | ||
.option("--include <patterns>", "Comma-separated list of patterns to include") | ||
.option("--ignore-default", "Disable default ignore patterns") | ||
.parse(process.argv); | ||
program.argument("<startPath>", "Starting directory path").option("--ignore <patterns>", "Comma-separated list of patterns to ignore").option("--include <patterns>", "Comma-separated list of patterns to include").option("--ignore-default", "Disable default ignore patterns").parse(process.argv); | ||
const startPath = program.args[0] && path.resolve(program.args[0]); | ||
@@ -51,7 +46,4 @@ const options = program.opts(); | ||
return patterns.some(pattern => { | ||
const regexPattern = pattern | ||
.split('*') | ||
.map(s => s.replace(/[|\\{}()[\]^$+?.]/g, '\\$&')) | ||
.join('.*'); | ||
const regex = new RegExp(regexPattern, 'i'); | ||
const regexPattern = pattern.split("*").map(s => s.replace(/[|\\{}()[\]^$+?.]/g, "\\$&")).join(".*"); | ||
const regex = new RegExp(regexPattern, "i"); | ||
console.log(`Checking ${filePath} against pattern: ${pattern} (regex: ${regex})`); | ||
@@ -65,15 +57,16 @@ const matches = regex.test(filePath); | ||
console.log(`\nChecking file: ${filePath}`); | ||
// First check if file matches ignore patterns | ||
// First check ignore patterns - they always apply | ||
const isIgnored = matchesPattern(filePath, ignorePatterns); | ||
console.log(`Ignore pattern match: ${isIgnored}`); | ||
if (isIgnored) { | ||
console.log(`File is ignored: ${filePath}`); | ||
return false; | ||
} | ||
// If we have include patterns, check if file matches them | ||
// If there are include patterns, file must match them | ||
if (includePatterns.length > 0) { | ||
const isIncluded = matchesPattern(filePath, includePatterns); | ||
console.log(`Include pattern match: ${isIncluded}`); | ||
// Include this file if it matches include patterns | ||
return isIncluded; | ||
} | ||
// If no include patterns, include all non-ignored files | ||
// If no include patterns and not ignored, include the file | ||
return true; | ||
@@ -88,5 +81,5 @@ } | ||
console.log(`\nProcessing: ${fullPath}`); | ||
// For directories, we always recurse unless they're explicitly ignored | ||
if (dirent.isDirectory()) { | ||
console.log(`${fullPath} is a directory`); | ||
// Directories are skipped only if they match ignore patterns | ||
if (!matchesPattern(fullPath, ignorePatterns)) { | ||
@@ -93,0 +86,0 @@ treeStructure[fullPath] = {}; |
{ | ||
"name": "print-project", | ||
"version": "1.0.14", | ||
"version": "1.0.15", | ||
"description": "A simple CLI tool to print the project tree structure and file contents", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -12,8 +12,3 @@ #!/usr/bin/env node | ||
const program = new Command(); | ||
program | ||
.argument("<startPath>", "Starting directory path") | ||
.option("--ignore <patterns>", "Comma-separated list of patterns to ignore") | ||
.option("--include <patterns>", "Comma-separated list of patterns to include") | ||
.option("--ignore-default", "Disable default ignore patterns") | ||
.parse(process.argv); | ||
program.argument("<startPath>", "Starting directory path").option("--ignore <patterns>", "Comma-separated list of patterns to ignore").option("--include <patterns>", "Comma-separated list of patterns to include").option("--ignore-default", "Disable default ignore patterns").parse(process.argv); | ||
@@ -31,8 +26,5 @@ const startPath: string | undefined = program.args[0] && path.resolve(program.args[0]); | ||
return patterns.some(pattern => { | ||
const regexPattern = pattern | ||
.split('*') | ||
.map(s => s.replace(/[|\\{}()[\]^$+?.]/g, '\\$&')) | ||
.join('.*'); | ||
const regexPattern = pattern.split("*").map(s => s.replace(/[|\\{}()[\]^$+?.]/g, "\\$&")).join(".*"); | ||
const regex = new RegExp(regexPattern, 'i'); | ||
const regex = new RegExp(regexPattern, "i"); | ||
console.log(`Checking ${filePath} against pattern: ${pattern} (regex: ${regex})`); | ||
@@ -48,17 +40,18 @@ const matches = regex.test(filePath); | ||
// First check if file matches ignore patterns | ||
// First check ignore patterns - they always apply | ||
const isIgnored = matchesPattern(filePath, ignorePatterns); | ||
console.log(`Ignore pattern match: ${isIgnored}`); | ||
if (isIgnored) { | ||
console.log(`File is ignored: ${filePath}`); | ||
return false; | ||
} | ||
// If we have include patterns, check if file matches them | ||
// If there are include patterns, file must match them | ||
if (includePatterns.length > 0) { | ||
const isIncluded = matchesPattern(filePath, includePatterns); | ||
console.log(`Include pattern match: ${isIncluded}`); | ||
// Include this file if it matches include patterns | ||
return isIncluded; | ||
} | ||
// If no include patterns, include all non-ignored files | ||
// If no include patterns and not ignored, include the file | ||
return true; | ||
@@ -76,5 +69,5 @@ } | ||
// For directories, we always recurse unless they're explicitly ignored | ||
if (dirent.isDirectory()) { | ||
console.log(`${fullPath} is a directory`); | ||
// Directories are skipped only if they match ignore patterns | ||
if (!matchesPattern(fullPath, ignorePatterns)) { | ||
@@ -87,3 +80,3 @@ treeStructure[fullPath] = {}; | ||
treeStructure[fullPath], | ||
fullPath | ||
fullPath, | ||
); | ||
@@ -90,0 +83,0 @@ } else { |
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
23423
480