Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

print-project

Package Overview
Dependencies
Maintainers
0
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

print-project - npm Package Compare versions

Comparing version 1.0.16 to 1.0.17

30

dist/index.js

@@ -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]);

@@ -47,17 +42,15 @@ const options = program.opts();

// Build the final ignore patterns list
let ignorePatterns = [];
// Always include project-print.txt in ignore patterns
const alwaysIgnore = ["project-print.txt"];
// If user specified --ignore-default, don't use default patterns
let ignorePatterns = ["project-print.txt"]; // Always ignore the output file
// If NOT using --ignore-default, add default patterns
if (!options.ignoreDefault) {
ignorePatterns = [...constants_1.defaultIgnorePatterns];
ignorePatterns = [...constants_1.defaultIgnorePatterns, ...ignorePatterns];
}
// Add user's ignore patterns
ignorePatterns = [...ignorePatterns, ...userIgnorePatterns, ...alwaysIgnore];
// Remove any patterns that match the include patterns
ignorePatterns = [...ignorePatterns, ...userIgnorePatterns];
// If we have include patterns, we should exclude any ignore patterns that would block them
if (includePatterns.length > 0) {
// Keep only ignore patterns that don't match any include patterns
ignorePatterns = ignorePatterns.filter(ignorePattern => {
return !includePatterns.some(includePattern => {
// If the ignore pattern matches any include pattern, remove it from ignores
const ignoreRegex = new RegExp(ignorePattern.replace(/\*/g, '.*'), 'i');
const ignoreRegex = new RegExp(ignorePattern.replace(/\*/g, ".*"), "i");
return ignoreRegex.test(includePattern);

@@ -69,7 +62,4 @@ });

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})`);

@@ -76,0 +66,0 @@ const matches = regex.test(filePath);

{
"name": "print-project",
"version": "1.0.16",
"version": "1.0.17",
"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);

@@ -26,21 +21,18 @@ const startPath: string | undefined = program.args[0] && path.resolve(program.args[0]);

// Build the final ignore patterns list
let ignorePatterns: string[] = [];
let ignorePatterns: string[] = ["project-print.txt"]; // Always ignore the output file
// Always include project-print.txt in ignore patterns
const alwaysIgnore = ["project-print.txt"];
// If user specified --ignore-default, don't use default patterns
// If NOT using --ignore-default, add default patterns
if (!options.ignoreDefault) {
ignorePatterns = [...defaultIgnorePatterns];
ignorePatterns = [...defaultIgnorePatterns, ...ignorePatterns];
}
// Add user's ignore patterns
ignorePatterns = [...ignorePatterns, ...userIgnorePatterns, ...alwaysIgnore];
ignorePatterns = [...ignorePatterns, ...userIgnorePatterns];
// Remove any patterns that match the include patterns
// If we have include patterns, we should exclude any ignore patterns that would block them
if (includePatterns.length > 0) {
// Keep only ignore patterns that don't match any include patterns
ignorePatterns = ignorePatterns.filter(ignorePattern => {
return !includePatterns.some(includePattern => {
// If the ignore pattern matches any include pattern, remove it from ignores
const ignoreRegex = new RegExp(ignorePattern.replace(/\*/g, '.*'), 'i');
const ignoreRegex = new RegExp(ignorePattern.replace(/\*/g, ".*"), "i");
return ignoreRegex.test(includePattern);

@@ -53,8 +45,5 @@ });

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})`);

@@ -61,0 +50,0 @@ const matches = regex.test(filePath);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc