print-project
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -53,4 +53,7 @@ #!/usr/bin/env node | ||
return patterns.some(pattern => { | ||
const parsedPattern = pattern.replace(/\./g, "\\.").replace(/\*/g, ".*"); | ||
const regex = new RegExp(parsedPattern); | ||
const escapedPattern = pattern | ||
.replace(/[.+^${}()|[\]\\]/g, '\\$&') | ||
.replace(/\*/g, '.*') | ||
.replace(/\?/g, '.'); | ||
const regex = new RegExp(`^${escapedPattern}$|/${escapedPattern}$|/${escapedPattern}/|^${escapedPattern}/`); | ||
return regex.test(filePath); | ||
@@ -60,3 +63,8 @@ }); | ||
function shouldIncludeFile(filePath, ignorePatterns, includePatterns) { | ||
return !matchesPattern(filePath, ignorePatterns) || matchesPattern(filePath, includePatterns); | ||
const isIgnored = matchesPattern(filePath, ignorePatterns); | ||
const isIncluded = includePatterns.length === 0 || matchesPattern(filePath, includePatterns); | ||
if (includePatterns.length > 0) { | ||
return isIncluded; | ||
} | ||
return !isIgnored; | ||
} | ||
@@ -63,0 +71,0 @@ function readDirectory(dirPath, ignorePatterns, includePatterns, treeStructure = {}, currentPath = "") { |
{ | ||
"name": "print-project", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "A simple CLI tool to print the project tree structure and file contents", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -34,4 +34,7 @@ #!/usr/bin/env node | ||
return patterns.some(pattern => { | ||
const parsedPattern = pattern.replace(/\./g, "\\.").replace(/\*/g, ".*"); | ||
const regex = new RegExp(parsedPattern); | ||
const escapedPattern = pattern | ||
.replace(/[.+^${}()|[\]\\]/g, '\\$&') | ||
.replace(/\*/g, '.*') | ||
.replace(/\?/g, '.'); | ||
const regex = new RegExp(`^${escapedPattern}$|/${escapedPattern}$|/${escapedPattern}/|^${escapedPattern}/`); | ||
return regex.test(filePath); | ||
@@ -42,3 +45,8 @@ }); | ||
function shouldIncludeFile(filePath: string, ignorePatterns: string[], includePatterns: string[]): boolean { | ||
return !matchesPattern(filePath, ignorePatterns) || matchesPattern(filePath, includePatterns); | ||
const isIgnored = matchesPattern(filePath, ignorePatterns); | ||
const isIncluded = includePatterns.length === 0 || matchesPattern(filePath, includePatterns); | ||
if (includePatterns.length > 0) { | ||
return isIncluded; | ||
} | ||
return !isIgnored; | ||
} | ||
@@ -45,0 +53,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
451
21853
16