@node-cli/search 2.0.1 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,64 +1,262 @@
1
- # Node CLI search package
1
+ # @node-cli/search
2
2
 
3
3
  ![npm](https://img.shields.io/npm/v/@node-cli/search?label=version&logo=npm)
4
4
 
5
- > Search is a command line tool that can:
6
- >
7
- > - find files or folders that match a certain pattern
8
- > - look for string within those files and display them (think shell commands "find" and "grep")
5
+ > A powerful and flexible command line tool for searching files and directories with advanced filtering capabilities. It combines the functionality of shell commands like "find" and "grep" with additional features for modern development workflows.
6
+
7
+ ## Features
8
+
9
+ - Find files or folders that match specific patterns
10
+ - Search for text within files using regular expressions
11
+ - Filter results by file type, extension, or name
12
+ - Respect `.gitignore` files (or optionally ignore them)
13
+ - Execute commands on matched files
14
+ - Output file content in different formats (simple text or XML) if needed
15
+ - Detailed statistics about search operations
9
16
 
10
17
  ## Installation
11
18
 
12
- This command line utility can be installed globally or locally within your project. It does make more sense to have it installed globally though, since it then can be use anywhere by simply starting it to search files and folders located in the current folder.
19
+ This command line utility can be installed globally or locally within your project. It makes more sense to install it globally so it can be used anywhere to search files and folders in the current directory.
20
+
21
+ ```sh
22
+ npm install --global @node-cli/search
23
+ ```
24
+
25
+ ## Command Line Usage
26
+
27
+ ### Help
28
+
29
+ To get help about available options and usage, run:
30
+
31
+ ```sh
32
+ search --help
33
+ ```
34
+
35
+ ### Basic Examples
36
+
37
+ **Find all files with the extension ".jsx" in the "src" folder:**
38
+
39
+ ```sh
40
+ search --type f --pattern "\.jsx$" src/
41
+ ```
42
+
43
+ **Find all files without the extensions "jsx" or "md" in the "src" folder:**
44
+
45
+ ```sh
46
+ search --type f --ignoreExtension jsx --ignoreExtension md src/
47
+ ```
48
+
49
+ **Change the permissions to executable for all shell scripts in the "bin" folder:**
50
+
51
+ ```sh
52
+ search --type f --pattern "\.sh$" --command "chmod +x" bin/
53
+ ```
54
+
55
+ **Search in all markdown files for the keywords "Table of Content":**
56
+
57
+ ```sh
58
+ search --type f --pattern "\.md$" --grep "Table of Content"
59
+ ```
60
+
61
+ **Find all files with the extension ".jsx" and print their content:**
13
62
 
14
63
  ```sh
15
- > npm install --global @node-cli/search
64
+ search --type f --pattern "\.jsx$" --printMode simple src/
16
65
  ```
17
66
 
18
- ## Examples
67
+ **Find all files with the extension ".jsx" and print their content in Claude XML format:**
68
+
69
+ ```sh
70
+ search --type f --pattern "\.jsx$" --printMode xml src/
71
+ ```
19
72
 
20
- Find all files with the extension ".jsx" in the "src" folder
73
+ ### Advanced Examples
74
+
75
+ **Find all files ignoring case sensitivity:**
21
76
 
22
77
  ```sh
23
- > search --type f --pattern ".jsx$" src/
78
+ search --type f --pattern "readme" --ignoreCase
24
79
  ```
25
80
 
26
- Find all files without the extension "jsx" or "md" in the "src" folder
81
+ **Find all hidden files:**
27
82
 
28
83
  ```sh
29
- > search --type f --ignore "jsx" --ignore "md" src/
84
+ search --type f --dot
30
85
  ```
31
86
 
32
- Change the permissions to executable for all the files with the extension ".sh" found under the "bin" folder
87
+ **Find all files ignoring specific folders:**
33
88
 
34
89
  ```sh
35
- > search --type f --pattern ".sh$" --command "chmod +x" bin/
90
+ search --type f --ignoreFolder node_modules --ignoreFolder dist
36
91
  ```
37
92
 
38
- Search in all the markdown files under the "src" folder for the keywords "Table of Content"
93
+ **Find all files ignoring specific file names:**
39
94
 
40
95
  ```sh
41
- > search --type f --pattern ".md$" --grep "Table of Content"
96
+ search --type f --ignoreFile README.md --ignoreFile CHANGELOG.md
42
97
  ```
43
98
 
44
- Find all files with the extension ".jsx" in the "src" folder and print their content
99
+ **Find all non-minified JavaScript files:**
45
100
 
46
101
  ```sh
47
- > search --type f --pattern ".jsx$" --printMode simple src/
102
+ search --type f --pattern "\.js$" --ignoreExtension min.js
48
103
  ```
49
104
 
50
- Find all files with the extension ".jsx" in the "src" folder and print their content in a Claude XML format
105
+ **Search for multiple patterns in TypeScript files:**
51
106
 
52
107
  ```sh
53
- > search --type f --pattern ".jsx$" --printMode xml src/
108
+ search --type f --pattern "\.ts$" --grep "export (class|function|const)"
54
109
  ```
55
110
 
56
- Get help
111
+ **Find all files ignoring .gitignore rules:**
57
112
 
58
113
  ```sh
59
- > search --help
114
+ search --type f --ignoreGitIgnore
60
115
  ```
61
116
 
117
+ ## Programmatic API Usage
118
+
119
+ The search functionality can also be used programmatically in your Node.js applications:
120
+
121
+ ```javascript
122
+ import { Search } from "@node-cli/search";
123
+
124
+ // Create a new search instance with configuration
125
+ const search = new Search({
126
+ // Path to search in
127
+ path: process.cwd(),
128
+
129
+ // Search for files only
130
+ type: "f",
131
+
132
+ // Pattern to match file names (as RegExp string)
133
+ pattern: ".js$",
134
+
135
+ // Case insensitive search
136
+ ignoreCase: true,
137
+
138
+ // Show hidden files
139
+ dot: true,
140
+
141
+ // Display statistics
142
+ stats: true,
143
+
144
+ // Extensions to ignore
145
+ ignoreExtension: ["min.js", "map"],
146
+
147
+ // Files to ignore
148
+ ignoreFile: ["package-lock.json"],
149
+
150
+ // Folders to ignore
151
+ ignoreFolder: ["node_modules", "dist"],
152
+
153
+ // Search for text within files
154
+ grep: "function",
155
+
156
+ // Command to execute on matched files
157
+ command: "wc -l",
158
+
159
+ // Output format
160
+ printMode: "simple", // or 'xml'
161
+
162
+ // Ignore .gitignore rules
163
+ ignoreGitIgnore: false,
164
+
165
+ // Short listing format
166
+ short: true,
167
+
168
+ // No color output
169
+ boring: false
170
+ });
171
+
172
+ // Start the search and print results to the console
173
+ await search.start();
174
+ ```
175
+
176
+ ### Returning Results Instead of Printing
177
+
178
+ By default, the search results are printed to the console. To get the results as a string instead, pass `true` to the `start()` method:
179
+
180
+ ```javascript
181
+ // For simple print mode
182
+ const search = new Search({
183
+ path: "./src",
184
+ type: "f",
185
+ pattern: ".ts$",
186
+ printMode: "simple"
187
+ });
188
+ const results = await search.start(true);
189
+ // results will contain the file contents in simple format
190
+ ```
191
+
192
+ ### XML Output Format
193
+
194
+ The XML output format is useful for parsing search results in other applications:
195
+
196
+ ```javascript
197
+ const search = new Search({
198
+ path: "./src",
199
+ type: "f",
200
+ pattern: ".ts$",
201
+ printMode: "xml"
202
+ });
203
+ const xmlResults = await search.start(true);
204
+ // xmlResults will contain the file contents in XML format
205
+ ```
206
+
207
+ ### Searching with Regular Expressions
208
+
209
+ You can use regular expressions for both file pattern matching and content searching:
210
+
211
+ ```javascript
212
+ const search = new Search({
213
+ path: "./src",
214
+ type: "f",
215
+ pattern: "(component|hook).tsx?$",
216
+ grep: "export\\s+const\\s+\\w+\\s*=\\s*\\(",
217
+ ignoreCase: true
218
+ });
219
+ await search.start();
220
+ ```
221
+
222
+ ### Filtering Options
223
+
224
+ The search utility provides multiple ways to filter results:
225
+
226
+ ```javascript
227
+ const search = new Search({
228
+ path: "./src",
229
+ type: "f",
230
+ // Ignore specific file extensions
231
+ ignoreExtension: ["test.ts", "spec.ts", "d.ts"],
232
+ // Ignore specific file names
233
+ ignoreFile: ["index.ts", "constants.ts"],
234
+ // Ignore specific folders
235
+ ignoreFolder: ["__tests__", "__mocks__"]
236
+ });
237
+ await search.start();
238
+ ```
239
+
240
+ ## Available Options
241
+
242
+ | Option | Type | Description |
243
+ | ----------------- | -------- | ------------------------------------------------------------------ |
244
+ | `path` | string | The path where to start the search (defaults to current directory) |
245
+ | `type` | string | Search for files ('f'), directories ('d'), or both ('both') |
246
+ | `pattern` | string | A regular expression to match file or folder names |
247
+ | `grep` | string | A regular expression to match the content of files |
248
+ | `ignoreCase` | boolean | Ignore case when searching |
249
+ | `dot` | boolean | Show hidden files and directories |
250
+ | `short` | boolean | Short listing format (equivalent to ls) |
251
+ | `stats` | boolean | Display search statistics |
252
+ | `command` | string | Command to execute over each matched node |
253
+ | `ignoreExtension` | string[] | File extensions to ignore |
254
+ | `ignoreFile` | string[] | File names to ignore |
255
+ | `ignoreFolder` | string[] | Folder names to ignore |
256
+ | `printMode` | string | Print mode ('simple' or 'xml') |
257
+ | `ignoreGitIgnore` | boolean | Ignore .gitignore files |
258
+ | `boring` | boolean | Do not use color output |
259
+
62
260
  ## License
63
261
 
64
262
  MIT © Arno Versini
package/dist/core.d.ts CHANGED
@@ -5,7 +5,6 @@ export declare class Search {
5
5
  displayHiddenFilesAndFolders?: boolean;
6
6
  displayLongListing?: boolean;
7
7
  displayStats?: boolean;
8
- foldersBlacklist?: RegExp;
9
8
  grep?: RegExp;
10
9
  nodesList?: any[];
11
10
  path?: string;
@@ -17,14 +16,14 @@ export declare class Search {
17
16
  type?: string;
18
17
  ignoreExtensions?: string[];
19
18
  ignoreFiles?: string[];
19
+ ignoreFolders?: string[];
20
20
  printMode?: string;
21
21
  gitIgnoreHandler: GitIgnoreHandler;
22
22
  ignoreGitIgnore?: boolean;
23
- constructor({ boring, command, dot, foldersBlacklist, grep, ignoreCase, short, path, pattern, stats, type, ignoreExtension, ignoreFile, printMode, ignoreGitIgnore, }: {
23
+ constructor({ boring, command, dot, grep, ignoreCase, short, path, pattern, stats, type, ignoreExtension, ignoreFile, ignoreFolder, printMode, ignoreGitIgnore, }: {
24
24
  boring?: boolean;
25
25
  command?: string;
26
26
  dot?: boolean;
27
- foldersBlacklist?: RegExp;
28
27
  grep?: string | RegExp;
29
28
  ignoreCase?: boolean;
30
29
  short?: boolean;
@@ -34,10 +33,11 @@ export declare class Search {
34
33
  type?: string;
35
34
  ignoreExtension?: string[];
36
35
  ignoreFile?: string[];
36
+ ignoreFolder?: string[];
37
37
  printMode?: string;
38
38
  ignoreGitIgnore?: boolean;
39
39
  });
40
- ignoreFolders(directory: string): boolean;
40
+ shouldIgnoreFolder(directory: string): boolean;
41
41
  shouldIgnoreFile(filePath: string): boolean;
42
42
  filterHidden(value: string[] | string): boolean;
43
43
  isBinaryFileExtension(filePath: string): boolean;
package/dist/core.js CHANGED
@@ -14,13 +14,15 @@ const perf = new Performance();
14
14
  const logger = new Logger({
15
15
  boring: process.env.NODE_ENV === "test"
16
16
  });
17
+ const loggerInMemory = new Logger({
18
+ inMemory: true
19
+ });
17
20
  export class Search {
18
21
  boring;
19
22
  command;
20
23
  displayHiddenFilesAndFolders;
21
24
  displayLongListing;
22
25
  displayStats;
23
- foldersBlacklist;
24
26
  grep;
25
27
  nodesList;
26
28
  path;
@@ -32,10 +34,11 @@ export class Search {
32
34
  type;
33
35
  ignoreExtensions;
34
36
  ignoreFiles;
37
+ ignoreFolders;
35
38
  printMode;
36
39
  gitIgnoreHandler;
37
40
  ignoreGitIgnore;
38
- constructor({ boring, command, dot, foldersBlacklist, grep, ignoreCase, short, path, pattern, stats, type, ignoreExtension, ignoreFile, printMode, ignoreGitIgnore }){
41
+ constructor({ boring, command, dot, grep, ignoreCase, short, path, pattern, stats, type, ignoreExtension, ignoreFile, ignoreFolder, printMode, ignoreGitIgnore }){
39
42
  this.path = path;
40
43
  this.rePattern = pattern ? new RegExp(pattern, ignoreCase ? "i" : "") : undefined;
41
44
  this.type = type || STR_TYPE_BOTH;
@@ -45,14 +48,14 @@ export class Search {
45
48
  this.displayStats = stats;
46
49
  this.displayHiddenFilesAndFolders = dot;
47
50
  this.nodesList = [];
48
- this.foldersBlacklist = foldersBlacklist;
49
51
  this.totalDirScanned = 0;
50
52
  this.totalFileScanned = 0;
51
53
  this.totalDirFound = 0;
52
54
  this.totalFileFound = 0;
53
55
  this.command = command ? command.trim() : undefined;
54
- this.ignoreExtensions = ignoreExtension.map((ext)=>ext.toLowerCase());
56
+ this.ignoreExtensions = ignoreExtension && ignoreExtension.map((ext)=>ext.toLowerCase()) || [];
55
57
  this.ignoreFiles = ignoreFile || [];
58
+ this.ignoreFolders = ignoreFolder || [];
56
59
  this.printMode = printMode;
57
60
  this.ignoreGitIgnore = ignoreGitIgnore;
58
61
  this.gitIgnoreHandler = new GitIgnoreHandler();
@@ -60,13 +63,16 @@ export class Search {
60
63
  this.grep = grep ? new RegExp(grep, ignoreCase ? "gi" : "g") : undefined;
61
64
  } catch (error) {
62
65
  logger.error(error);
63
- // eslint-disable-next-line unicorn/no-process-exit
64
66
  process.exit(1);
65
67
  }
66
68
  }
67
- ignoreFolders(directory) {
68
- this.foldersBlacklist.lastIndex = 0;
69
- return this.foldersBlacklist.test(basename(directory));
69
+ shouldIgnoreFolder(directory) {
70
+ const folderName = basename(directory);
71
+ // Check for exact folder name match
72
+ if (this.ignoreFolders && this.ignoreFolders.includes(folderName)) {
73
+ return true;
74
+ }
75
+ return false;
70
76
  }
71
77
  shouldIgnoreFile(filePath) {
72
78
  // First check if the file is in the ignoreFiles list
@@ -203,7 +209,7 @@ export class Search {
203
209
  if (await this.shouldIgnoreByGitIgnore(node, isDirectory)) {
204
210
  continue;
205
211
  }
206
- if (isDirectory && !this.ignoreFolders(node)) {
212
+ if (isDirectory && !this.shouldIgnoreFolder(node)) {
207
213
  this.totalDirScanned++;
208
214
  result = checkPattern(this.rePattern, node);
209
215
  if (result) {
@@ -259,25 +265,24 @@ export class Search {
259
265
  }
260
266
  async printFilesContent(returnResults) {
261
267
  const fileNodes = this.nodesList.filter((node)=>node.type === STR_TYPE_FILE);
262
- let results = "";
263
268
  if (this.printMode === "simple") {
264
269
  for (const node of fileNodes){
265
270
  const relativePath = relative(this.path, node.name);
266
271
  if (returnResults) {
267
- results += `---\n./${relativePath}\n---\n`;
272
+ loggerInMemory.log(`---\n./${relativePath}\n---`);
268
273
  } else {
269
274
  logger.log(`---\n./${relativePath}\n---`);
270
275
  }
271
276
  const content = await this.readFileContent(node.name);
272
277
  if (returnResults) {
273
- results += `${content}\n`;
278
+ loggerInMemory.log(content);
274
279
  } else {
275
280
  logger.log(content);
276
281
  }
277
282
  // adding a new line after each file content except the last one
278
283
  if (node !== fileNodes[fileNodes.length - 1]) {
279
284
  if (returnResults) {
280
- results += "\n";
285
+ loggerInMemory.log("");
281
286
  } else {
282
287
  logger.log("");
283
288
  }
@@ -285,7 +290,7 @@ export class Search {
285
290
  }
286
291
  } else if (this.printMode === "xml") {
287
292
  if (returnResults) {
288
- results += "<documents>\n";
293
+ loggerInMemory.log("<documents>");
289
294
  } else {
290
295
  logger.log("<documents>");
291
296
  }
@@ -294,12 +299,12 @@ export class Search {
294
299
  const relativePath = relative(this.path, node.name);
295
300
  const content = await this.readFileContent(node.name);
296
301
  if (returnResults) {
297
- results += `<document index="${i + 1}">\n`;
298
- results += `<source>./${relativePath}</source>\n`;
299
- results += "<document_content>\n";
300
- results += `${content}\n`;
301
- results += "</document_content>\n";
302
- results += "</document>\n";
302
+ loggerInMemory.log(`<document index="${i + 1}">`);
303
+ loggerInMemory.log(`<source>./${relativePath}</source>`);
304
+ loggerInMemory.log("<document_content>");
305
+ loggerInMemory.log(content);
306
+ loggerInMemory.log("</document_content>");
307
+ loggerInMemory.log("</document>");
303
308
  } else {
304
309
  logger.log(`<document index="${i + 1}">`);
305
310
  logger.log(`<source>./${relativePath}</source>`);
@@ -310,11 +315,13 @@ export class Search {
310
315
  }
311
316
  }
312
317
  if (returnResults) {
313
- results += "</documents>";
318
+ loggerInMemory.log("</documents>");
314
319
  } else {
315
320
  logger.log("</documents>");
316
321
  }
317
322
  }
323
+ const results = returnResults ? loggerInMemory.getMemoryLogs() : undefined;
324
+ loggerInMemory.clearMemoryLogs();
318
325
  return results;
319
326
  }
320
327
  async shouldIgnoreByGitIgnore(nodePath, isDirectory) {
@@ -324,9 +331,6 @@ export class Search {
324
331
  return this.gitIgnoreHandler.isIgnored(nodePath, isDirectory);
325
332
  }
326
333
  async postProcessResults(returnResults) {
327
- /* istanbul ignore if */ if (!this.boring) {
328
- logger.log();
329
- }
330
334
  if (this.grep) {
331
335
  /**
332
336
  * Resetting the number of files found, since we want to
@@ -341,6 +345,9 @@ export class Search {
341
345
  ].includes(this.printMode)) {
342
346
  return await this.printFilesContent(returnResults);
343
347
  }
348
+ /* istanbul ignore if */ if (!this.boring) {
349
+ logger.log();
350
+ }
344
351
  for (const node of this.nodesList){
345
352
  if (this.type === STR_TYPE_FILE && node.type === STR_TYPE_FILE || this.type === STR_TYPE_DIRECTORY && node.type === STR_TYPE_DIRECTORY || this.type === STR_TYPE_BOTH) {
346
353
  let list = {
package/dist/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core.ts"],"sourcesContent":["import { basename, extname, join, relative } from \"node:path\";\n\nimport { GitIgnoreHandler } from \"./gitIgnoreHandler.js\";\nimport {\n\tSTR_TYPE_BOTH,\n\tSTR_TYPE_DIRECTORY,\n\tSTR_TYPE_FILE,\n\tcheckPattern,\n\tformatLongListings,\n\tprintStatistics,\n\trunCommandOnNode,\n\trunGrepOnNode,\n} from \"./utilities.js\";\n\nimport { promisify } from \"node:util\";\nimport { Logger } from \"@node-cli/logger\";\nimport { Performance } from \"@node-cli/perf\";\nimport fs from \"fs-extra\";\nimport kleur from \"kleur\";\nimport plur from \"plur\";\n\nconst lstatAsync = promisify(fs.lstat);\nconst readdirAsync = promisify(fs.readdir);\nconst readFileAsync = promisify(fs.readFile);\nconst perf = new Performance();\nconst logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\n\nexport class Search {\n\tboring?: boolean;\n\tcommand?: string;\n\tdisplayHiddenFilesAndFolders?: boolean;\n\tdisplayLongListing?: boolean;\n\tdisplayStats?: boolean;\n\tfoldersBlacklist?: RegExp;\n\tgrep?: RegExp;\n\tnodesList?: any[];\n\tpath?: string;\n\trePattern?: RegExp;\n\ttotalDirFound?: number;\n\ttotalDirScanned?: number;\n\ttotalFileFound?: number;\n\ttotalFileScanned?: number;\n\ttype?: string;\n\tignoreExtensions?: string[];\n\tignoreFiles?: string[];\n\tprintMode?: string;\n\tgitIgnoreHandler: GitIgnoreHandler;\n\tignoreGitIgnore?: boolean;\n\n\tconstructor({\n\t\tboring,\n\t\tcommand,\n\t\tdot,\n\t\tfoldersBlacklist,\n\t\tgrep,\n\t\tignoreCase,\n\t\tshort,\n\t\tpath,\n\t\tpattern,\n\t\tstats,\n\t\ttype,\n\t\tignoreExtension,\n\t\tignoreFile,\n\t\tprintMode,\n\t\tignoreGitIgnore,\n\t}: {\n\t\tboring?: boolean;\n\t\tcommand?: string;\n\t\tdot?: boolean;\n\t\tfoldersBlacklist?: RegExp;\n\t\tgrep?: string | RegExp;\n\t\tignoreCase?: boolean;\n\t\tshort?: boolean;\n\t\tpath?: string;\n\t\tpattern?: string;\n\t\tstats?: boolean;\n\t\ttype?: string;\n\t\tignoreExtension?: string[];\n\t\tignoreFile?: string[];\n\t\tprintMode?: string;\n\t\tignoreGitIgnore?: boolean;\n\t}) {\n\t\tthis.path = path;\n\t\tthis.rePattern = pattern\n\t\t\t? new RegExp(pattern, ignoreCase ? \"i\" : \"\")\n\t\t\t: undefined;\n\t\tthis.type = type || STR_TYPE_BOTH;\n\t\tthis.boring = boring;\n\t\tkleur.enabled = !boring;\n\t\tthis.displayLongListing = !short;\n\t\tthis.displayStats = stats;\n\t\tthis.displayHiddenFilesAndFolders = dot;\n\t\tthis.nodesList = [];\n\t\tthis.foldersBlacklist = foldersBlacklist;\n\t\tthis.totalDirScanned = 0;\n\t\tthis.totalFileScanned = 0;\n\t\tthis.totalDirFound = 0;\n\t\tthis.totalFileFound = 0;\n\t\tthis.command = command ? command.trim() : undefined;\n\t\tthis.ignoreExtensions = ignoreExtension.map((ext) => ext.toLowerCase());\n\t\tthis.ignoreFiles = ignoreFile || [];\n\t\tthis.printMode = printMode;\n\t\tthis.ignoreGitIgnore = ignoreGitIgnore;\n\t\tthis.gitIgnoreHandler = new GitIgnoreHandler();\n\t\ttry {\n\t\t\tthis.grep = grep ? new RegExp(grep, ignoreCase ? \"gi\" : \"g\") : undefined;\n\t\t} catch (error) {\n\t\t\tlogger.error(error);\n\t\t\t// eslint-disable-next-line unicorn/no-process-exit\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\tignoreFolders(directory: string) {\n\t\tthis.foldersBlacklist.lastIndex = 0;\n\t\treturn this.foldersBlacklist.test(basename(directory));\n\t}\n\n\tshouldIgnoreFile(filePath: string) {\n\t\t// First check if the file is in the ignoreFiles list\n\t\tconst filename = basename(filePath);\n\t\tif (this.ignoreFiles && this.ignoreFiles.includes(filename)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Then check if the extension should be ignored\n\t\tif (!this.ignoreExtensions || this.ignoreExtensions.length === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst extension = extname(filePath).toLowerCase().replace(/^\\./, \"\");\n\n\t\t// Check for exact extension match\n\t\tif (this.ignoreExtensions.includes(extension)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Check for complex patterns like \"min.js\"\n\t\tfor (const pattern of this.ignoreExtensions) {\n\t\t\t// Skip patterns that don't contain a dot\n\t\t\tif (!pattern.includes(\".\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Check if the filename ends with the pattern\n\t\t\tif (filename.toLowerCase().endsWith(`.${pattern}`)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tfilterHidden(value: string[] | string) {\n\t\tif (this.displayHiddenFilesAndFolders) {\n\t\t\treturn true;\n\t\t}\n\t\treturn value[0] !== \".\";\n\t}\n\n\tisBinaryFileExtension(filePath: string): boolean {\n\t\tconst ext = extname(filePath).toLowerCase().replace(/^\\./, \"\");\n\n\t\t// If there's no extension, assume it's binary\n\t\t/* istanbul ignore if */\n\t\tif (!ext) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst binaryExtensions = [\n\t\t\t// Executables and compiled code\n\t\t\t\"exe\",\n\t\t\t\"dll\",\n\t\t\t\"so\",\n\t\t\t\"dylib\",\n\t\t\t\"bin\",\n\t\t\t\"obj\",\n\t\t\t\"o\",\n\t\t\t// Compressed files\n\t\t\t\"zip\",\n\t\t\t\"tar\",\n\t\t\t\"gz\",\n\t\t\t\"rar\",\n\t\t\t\"7z\",\n\t\t\t\"jar\",\n\t\t\t\"war\",\n\t\t\t// Media files\n\t\t\t\"jpg\",\n\t\t\t\"jpeg\",\n\t\t\t\"png\",\n\t\t\t\"gif\",\n\t\t\t\"bmp\",\n\t\t\t\"ico\",\n\t\t\t\"tif\",\n\t\t\t\"tiff\",\n\t\t\t\"mp3\",\n\t\t\t\"mp4\",\n\t\t\t\"avi\",\n\t\t\t\"mov\",\n\t\t\t\"wmv\",\n\t\t\t\"flv\",\n\t\t\t\"wav\",\n\t\t\t\"ogg\",\n\t\t\t// Document formats\n\t\t\t\"pdf\",\n\t\t\t\"doc\",\n\t\t\t\"docx\",\n\t\t\t\"xls\",\n\t\t\t\"xlsx\",\n\t\t\t\"ppt\",\n\t\t\t\"pptx\",\n\t\t\t// Database files\n\t\t\t\"db\",\n\t\t\t\"sqlite\",\n\t\t\t\"mdb\",\n\t\t\t// Other binary formats\n\t\t\t\"class\",\n\t\t\t\"pyc\",\n\t\t\t\"pyd\",\n\t\t\t\"pyo\",\n\t\t\t\"woff\",\n\t\t\t\"woff2\",\n\t\t\t\"ttf\",\n\t\t\t\"otf\",\n\t\t];\n\n\t\treturn binaryExtensions.includes(ext);\n\t}\n\n\tasync start(returnResults = false) {\n\t\tif (this.displayStats) {\n\t\t\tperf.start();\n\t\t}\n\t\tawait this.scanFileSystem([this.path]);\n\t\tconst results = await this.postProcessResults(returnResults);\n\n\t\tif (this.displayStats) {\n\t\t\tperf.stop();\n\t\t\tprintStatistics({\n\t\t\t\tduration: perf.results.duration,\n\t\t\t\tgrep: this.grep,\n\t\t\t\tpattern: this.rePattern,\n\t\t\t\ttotalDirScanned: this.totalDirScanned,\n\t\t\t\ttotalDirsFound: this.totalDirFound,\n\t\t\t\ttotalFileScanned: this.totalFileScanned,\n\t\t\t\ttotalFilesFound: this.totalFileFound,\n\t\t\t\ttype: this.type,\n\t\t\t});\n\t\t}\n\t\treturn returnResults ? results : undefined;\n\t}\n\n\tasync scanFileSystem(nodes: string[]) {\n\t\tfor (const node of nodes) {\n\t\t\tlet result: boolean | RegExpExecArray,\n\t\t\t\tfiles: string[],\n\t\t\t\tshortname: string,\n\t\t\t\tstat: fs.Stats;\n\t\t\ttry {\n\t\t\t\tstat = await lstatAsync(node);\n\t\t\t} catch {\n\t\t\t\t// ignore read permission denied errors silently...\n\t\t\t}\n\n\t\t\tconst isDirectory = stat && stat.isDirectory();\n\t\t\tconst isFile = stat && stat.isFile();\n\n\t\t\t// Add this check to respect .gitignore patterns\n\t\t\tif (await this.shouldIgnoreByGitIgnore(node, isDirectory)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isDirectory && !this.ignoreFolders(node)) {\n\t\t\t\tthis.totalDirScanned++;\n\n\t\t\t\tresult = checkPattern(this.rePattern, node);\n\t\t\t\tif (result) {\n\t\t\t\t\tthis.totalDirFound++;\n\t\t\t\t\tthis.nodesList.push({\n\t\t\t\t\t\tcommand: this.command,\n\t\t\t\t\t\tmatch: result,\n\t\t\t\t\t\tname: node,\n\t\t\t\t\t\tstat,\n\t\t\t\t\t\ttype: STR_TYPE_DIRECTORY,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tfiles = await readdirAsync(node);\n\t\t\t\t\tawait this.scanFileSystem(\n\t\t\t\t\t\tfiles\n\t\t\t\t\t\t\t.filter((element) => this.filterHidden(element))\n\t\t\t\t\t\t\t.map(function (file) {\n\t\t\t\t\t\t\t\treturn join(node, file);\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t} catch {\n\t\t\t\t\t// nothing to declare\n\t\t\t\t}\n\t\t\t} else if (isFile) {\n\t\t\t\t// Skip files with ignored extensions\n\t\t\t\tif (this.shouldIgnoreFile(node)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tthis.totalFileScanned++;\n\t\t\t\tshortname = basename(node);\n\t\t\t\tconst patternResult = checkPattern(this.rePattern, shortname);\n\t\t\t\tif (patternResult) {\n\t\t\t\t\tthis.totalFileFound++;\n\t\t\t\t\tthis.nodesList.push({\n\t\t\t\t\t\tcommand: this.command,\n\t\t\t\t\t\tmatch: patternResult[0],\n\t\t\t\t\t\tname: node,\n\t\t\t\t\t\tstat,\n\t\t\t\t\t\ttype: STR_TYPE_FILE,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tasync readFileContent(filePath: string): Promise<string> {\n\t\ttry {\n\t\t\t// Check if it's a known binary extension\n\t\t\t/* istanbul ignore if */\n\t\t\tif (this.isBinaryFileExtension(filePath)) {\n\t\t\t\treturn \"[Binary file]\";\n\t\t\t}\n\t\t\tconst content = await readFileAsync(filePath, \"utf8\");\n\t\t\treturn content;\n\t\t} catch (error) {\n\t\t\t/* istanbul ignore next */\n\t\t\treturn `Error reading file: ${error.message}`;\n\t\t}\n\t}\n\n\tasync printFilesContent(returnResults: boolean) {\n\t\tconst fileNodes = this.nodesList.filter(\n\t\t\t(node) => node.type === STR_TYPE_FILE,\n\t\t);\n\n\t\tlet results = \"\";\n\t\tif (this.printMode === \"simple\") {\n\t\t\tfor (const node of fileNodes) {\n\t\t\t\tconst relativePath = relative(this.path, node.name);\n\t\t\t\tif (returnResults) {\n\t\t\t\t\tresults += `---\\n./${relativePath}\\n---\\n`;\n\t\t\t\t} else {\n\t\t\t\t\tlogger.log(`---\\n./${relativePath}\\n---`);\n\t\t\t\t}\n\t\t\t\tconst content = await this.readFileContent(node.name);\n\t\t\t\tif (returnResults) {\n\t\t\t\t\tresults += `${content}\\n`;\n\t\t\t\t} else {\n\t\t\t\t\tlogger.log(content);\n\t\t\t\t}\n\t\t\t\t// adding a new line after each file content except the last one\n\t\t\t\tif (node !== fileNodes[fileNodes.length - 1]) {\n\t\t\t\t\tif (returnResults) {\n\t\t\t\t\t\tresults += \"\\n\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.log(\"\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.printMode === \"xml\") {\n\t\t\tif (returnResults) {\n\t\t\t\tresults += \"<documents>\\n\";\n\t\t\t} else {\n\t\t\t\tlogger.log(\"<documents>\");\n\t\t\t}\n\n\t\t\tfor (let i = 0; i < fileNodes.length; i++) {\n\t\t\t\tconst node = fileNodes[i];\n\t\t\t\tconst relativePath = relative(this.path, node.name);\n\t\t\t\tconst content = await this.readFileContent(node.name);\n\n\t\t\t\tif (returnResults) {\n\t\t\t\t\tresults += `<document index=\"${i + 1}\">\\n`;\n\t\t\t\t\tresults += `<source>./${relativePath}</source>\\n`;\n\t\t\t\t\tresults += \"<document_content>\\n\";\n\t\t\t\t\tresults += `${content}\\n`;\n\t\t\t\t\tresults += \"</document_content>\\n\";\n\t\t\t\t\tresults += \"</document>\\n\";\n\t\t\t\t} else {\n\t\t\t\t\tlogger.log(`<document index=\"${i + 1}\">`);\n\t\t\t\t\tlogger.log(`<source>./${relativePath}</source>`);\n\t\t\t\t\tlogger.log(\"<document_content>\");\n\t\t\t\t\tlogger.log(content);\n\t\t\t\t\tlogger.log(\"</document_content>\");\n\t\t\t\t\tlogger.log(\"</document>\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (returnResults) {\n\t\t\t\tresults += \"</documents>\";\n\t\t\t} else {\n\t\t\t\tlogger.log(\"</documents>\");\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n\n\tasync shouldIgnoreByGitIgnore(\n\t\tnodePath: string,\n\t\tisDirectory: boolean,\n\t): Promise<boolean> {\n\t\t/* istanbul ignore if */\n\t\tif (this.ignoreGitIgnore) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.gitIgnoreHandler.isIgnored(nodePath, isDirectory);\n\t}\n\n\tasync postProcessResults(returnResults: boolean) {\n\t\t/* istanbul ignore if */\n\t\tif (!this.boring) {\n\t\t\tlogger.log();\n\t\t}\n\n\t\tif (this.grep) {\n\t\t\t/**\n\t\t\t * Resetting the number of files found, since we want to\n\t\t\t * show how many matched the grep, not how many matched the\n\t\t\t * pattern (in the file name).\n\t\t\t */\n\t\t\tthis.totalFileFound = 0;\n\t\t}\n\n\t\t// If printMode is enabled, handle file content printing and return\n\t\tif (this.printMode && [\"simple\", \"xml\"].includes(this.printMode)) {\n\t\t\treturn await this.printFilesContent(returnResults);\n\t\t}\n\n\t\tfor (const node of this.nodesList) {\n\t\t\tif (\n\t\t\t\t(this.type === STR_TYPE_FILE && node.type === STR_TYPE_FILE) ||\n\t\t\t\t(this.type === STR_TYPE_DIRECTORY &&\n\t\t\t\t\tnode.type === STR_TYPE_DIRECTORY) ||\n\t\t\t\tthis.type === STR_TYPE_BOTH\n\t\t\t) {\n\t\t\t\tlet list: {\n\t\t\t\t\t\tgroup?: string;\n\t\t\t\t\t\tmdate?: string;\n\t\t\t\t\t\tmode?: string;\n\t\t\t\t\t\towner?: string;\n\t\t\t\t\t\tsize?: string;\n\t\t\t\t\t} = {\n\t\t\t\t\t\tgroup: \"\",\n\t\t\t\t\t\tmdate: \"\",\n\t\t\t\t\t\tmode: \"\",\n\t\t\t\t\t\towner: \"\",\n\t\t\t\t\t\tsize: \"\",\n\t\t\t\t\t},\n\t\t\t\t\tname: string,\n\t\t\t\t\tseparator: string = \"\";\n\n\t\t\t\t/* istanbul ignore if */\n\t\t\t\tif (this.displayLongListing) {\n\t\t\t\t\tlist = await formatLongListings(node.stat, node.type);\n\t\t\t\t\tseparator = \"\\t\";\n\t\t\t\t}\n\n\t\t\t\tconst color = node.type === STR_TYPE_FILE ? kleur.gray : kleur.blue;\n\t\t\t\tname = relative(this.path, node.name);\n\n\t\t\t\tif (node.match) {\n\t\t\t\t\tconst matchStr = String(node.match); // Ensure match is a string\n\t\t\t\t\tconst match = new RegExp(matchStr, \"g\");\n\t\t\t\t\tconst highlightedMatch = kleur.black().bgYellow(matchStr);\n\t\t\t\t\tname = color(name.replace(match, highlightedMatch));\n\t\t\t\t} else {\n\t\t\t\t\tname = color(name);\n\t\t\t\t}\n\n\t\t\t\tif (this.grep && node.type === STR_TYPE_FILE) {\n\t\t\t\t\tconst { totalMatchingLines, results } = await runGrepOnNode(\n\t\t\t\t\t\tnode.name,\n\t\t\t\t\t\tthis.grep,\n\t\t\t\t\t);\n\t\t\t\t\t/* istanbul ignore else */\n\t\t\t\t\tif (totalMatchingLines) {\n\t\t\t\t\t\tthis.totalFileFound++;\n\t\t\t\t\t\tconst occurrences = plur(\"occurrence\", totalMatchingLines);\n\n\t\t\t\t\t\tlogger.log(\n\t\t\t\t\t\t\t` %s${separator}%s${separator}%s${separator}%s${separator}%s`,\n\t\t\t\t\t\t\tlist.mode.trim(),\n\t\t\t\t\t\t\tlist.owner.trim(),\n\t\t\t\t\t\t\tlist.size.trim(),\n\t\t\t\t\t\t\tlist.mdate,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t`(${kleur.white(totalMatchingLines)} ${occurrences})`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlogger.log(`${results.join(\"\\n\")}\\n`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t/* istanbul ignore next */\n\t\t\t\t\tif (!this.grep) {\n\t\t\t\t\t\tlogger.log(\n\t\t\t\t\t\t\t` %s${separator}%s${separator}%s${separator}%s${separator}%s`,\n\t\t\t\t\t\t\tlist.mode.trim(),\n\t\t\t\t\t\t\tlist.owner.trim(),\n\t\t\t\t\t\t\tlist.size.trim(),\n\t\t\t\t\t\t\tlist.mdate,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (node.command) {\n\t\t\t\t\t\t\tawait runCommandOnNode(node.name, node.command);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["basename","extname","join","relative","GitIgnoreHandler","STR_TYPE_BOTH","STR_TYPE_DIRECTORY","STR_TYPE_FILE","checkPattern","formatLongListings","printStatistics","runCommandOnNode","runGrepOnNode","promisify","Logger","Performance","fs","kleur","plur","lstatAsync","lstat","readdirAsync","readdir","readFileAsync","readFile","perf","logger","boring","process","env","NODE_ENV","Search","command","displayHiddenFilesAndFolders","displayLongListing","displayStats","foldersBlacklist","grep","nodesList","path","rePattern","totalDirFound","totalDirScanned","totalFileFound","totalFileScanned","type","ignoreExtensions","ignoreFiles","printMode","gitIgnoreHandler","ignoreGitIgnore","constructor","dot","ignoreCase","short","pattern","stats","ignoreExtension","ignoreFile","RegExp","undefined","enabled","trim","map","ext","toLowerCase","error","exit","ignoreFolders","directory","lastIndex","test","shouldIgnoreFile","filePath","filename","includes","length","extension","replace","endsWith","filterHidden","value","isBinaryFileExtension","binaryExtensions","start","returnResults","scanFileSystem","results","postProcessResults","stop","duration","totalDirsFound","totalFilesFound","nodes","node","result","files","shortname","stat","isDirectory","isFile","shouldIgnoreByGitIgnore","push","match","name","filter","element","file","patternResult","readFileContent","content","message","printFilesContent","fileNodes","relativePath","log","i","nodePath","isIgnored","list","group","mdate","mode","owner","size","separator","color","gray","blue","matchStr","String","highlightedMatch","black","bgYellow","totalMatchingLines","occurrences","white"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,YAAY;AAE9D,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SACCC,aAAa,EACbC,kBAAkB,EAClBC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,QACP,iBAAiB;AAExB,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,UAAU,OAAO;AAExB,MAAMC,aAAaN,UAAUG,GAAGI,KAAK;AACrC,MAAMC,eAAeR,UAAUG,GAAGM,OAAO;AACzC,MAAMC,gBAAgBV,UAAUG,GAAGQ,QAAQ;AAC3C,MAAMC,OAAO,IAAIV;AACjB,MAAMW,SAAS,IAAIZ,OAAO;IACzBa,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK;AAClC;AAEA,OAAO,MAAMC;IACZJ,OAAiB;IACjBK,QAAiB;IACjBC,6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ACD;AACD"}
1
+ {"version":3,"sources":["../src/core.ts"],"sourcesContent":["import { basename, extname, join, relative } from \"node:path\";\n\nimport { GitIgnoreHandler } from \"./gitIgnoreHandler.js\";\nimport {\n\tSTR_TYPE_BOTH,\n\tSTR_TYPE_DIRECTORY,\n\tSTR_TYPE_FILE,\n\tcheckPattern,\n\tformatLongListings,\n\tprintStatistics,\n\trunCommandOnNode,\n\trunGrepOnNode,\n} from \"./utilities.js\";\n\nimport { promisify } from \"node:util\";\nimport { Logger } from \"@node-cli/logger\";\nimport { Performance } from \"@node-cli/perf\";\nimport fs from \"fs-extra\";\nimport kleur from \"kleur\";\nimport plur from \"plur\";\n\nconst lstatAsync = promisify(fs.lstat);\nconst readdirAsync = promisify(fs.readdir);\nconst readFileAsync = promisify(fs.readFile);\nconst perf = new Performance();\nconst logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\nconst loggerInMemory = new Logger({\n\tinMemory: true,\n});\n\nexport class Search {\n\tboring?: boolean;\n\tcommand?: string;\n\tdisplayHiddenFilesAndFolders?: boolean;\n\tdisplayLongListing?: boolean;\n\tdisplayStats?: boolean;\n\tgrep?: RegExp;\n\tnodesList?: any[];\n\tpath?: string;\n\trePattern?: RegExp;\n\ttotalDirFound?: number;\n\ttotalDirScanned?: number;\n\ttotalFileFound?: number;\n\ttotalFileScanned?: number;\n\ttype?: string;\n\tignoreExtensions?: string[];\n\tignoreFiles?: string[];\n\tignoreFolders?: string[];\n\tprintMode?: string;\n\tgitIgnoreHandler: GitIgnoreHandler;\n\tignoreGitIgnore?: boolean;\n\n\tconstructor({\n\t\tboring,\n\t\tcommand,\n\t\tdot,\n\t\tgrep,\n\t\tignoreCase,\n\t\tshort,\n\t\tpath,\n\t\tpattern,\n\t\tstats,\n\t\ttype,\n\t\tignoreExtension,\n\t\tignoreFile,\n\t\tignoreFolder,\n\t\tprintMode,\n\t\tignoreGitIgnore,\n\t}: {\n\t\tboring?: boolean;\n\t\tcommand?: string;\n\t\tdot?: boolean;\n\t\tgrep?: string | RegExp;\n\t\tignoreCase?: boolean;\n\t\tshort?: boolean;\n\t\tpath?: string;\n\t\tpattern?: string;\n\t\tstats?: boolean;\n\t\ttype?: string;\n\t\tignoreExtension?: string[];\n\t\tignoreFile?: string[];\n\t\tignoreFolder?: string[];\n\t\tprintMode?: string;\n\t\tignoreGitIgnore?: boolean;\n\t}) {\n\t\tthis.path = path;\n\t\tthis.rePattern = pattern\n\t\t\t? new RegExp(pattern, ignoreCase ? \"i\" : \"\")\n\t\t\t: undefined;\n\t\tthis.type = type || STR_TYPE_BOTH;\n\t\tthis.boring = boring;\n\t\tkleur.enabled = !boring;\n\t\tthis.displayLongListing = !short;\n\t\tthis.displayStats = stats;\n\t\tthis.displayHiddenFilesAndFolders = dot;\n\t\tthis.nodesList = [];\n\t\tthis.totalDirScanned = 0;\n\t\tthis.totalFileScanned = 0;\n\t\tthis.totalDirFound = 0;\n\t\tthis.totalFileFound = 0;\n\t\tthis.command = command ? command.trim() : undefined;\n\t\tthis.ignoreExtensions =\n\t\t\t(ignoreExtension && ignoreExtension.map((ext) => ext.toLowerCase())) ||\n\t\t\t[];\n\t\tthis.ignoreFiles = ignoreFile || [];\n\t\tthis.ignoreFolders = ignoreFolder || [];\n\t\tthis.printMode = printMode;\n\t\tthis.ignoreGitIgnore = ignoreGitIgnore;\n\t\tthis.gitIgnoreHandler = new GitIgnoreHandler();\n\t\ttry {\n\t\t\tthis.grep = grep ? new RegExp(grep, ignoreCase ? \"gi\" : \"g\") : undefined;\n\t\t} catch (error) {\n\t\t\tlogger.error(error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\tshouldIgnoreFolder(directory: string) {\n\t\tconst folderName = basename(directory);\n\t\t// Check for exact folder name match\n\t\tif (this.ignoreFolders && this.ignoreFolders.includes(folderName)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tshouldIgnoreFile(filePath: string) {\n\t\t// First check if the file is in the ignoreFiles list\n\t\tconst filename = basename(filePath);\n\t\tif (this.ignoreFiles && this.ignoreFiles.includes(filename)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Then check if the extension should be ignored\n\t\tif (!this.ignoreExtensions || this.ignoreExtensions.length === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst extension = extname(filePath).toLowerCase().replace(/^\\./, \"\");\n\n\t\t// Check for exact extension match\n\t\tif (this.ignoreExtensions.includes(extension)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Check for complex patterns like \"min.js\"\n\t\tfor (const pattern of this.ignoreExtensions) {\n\t\t\t// Skip patterns that don't contain a dot\n\t\t\tif (!pattern.includes(\".\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Check if the filename ends with the pattern\n\t\t\tif (filename.toLowerCase().endsWith(`.${pattern}`)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tfilterHidden(value: string[] | string) {\n\t\tif (this.displayHiddenFilesAndFolders) {\n\t\t\treturn true;\n\t\t}\n\t\treturn value[0] !== \".\";\n\t}\n\n\tisBinaryFileExtension(filePath: string): boolean {\n\t\tconst ext = extname(filePath).toLowerCase().replace(/^\\./, \"\");\n\n\t\t// If there's no extension, assume it's binary\n\t\t/* istanbul ignore if */\n\t\tif (!ext) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst binaryExtensions = [\n\t\t\t// Executables and compiled code\n\t\t\t\"exe\",\n\t\t\t\"dll\",\n\t\t\t\"so\",\n\t\t\t\"dylib\",\n\t\t\t\"bin\",\n\t\t\t\"obj\",\n\t\t\t\"o\",\n\t\t\t// Compressed files\n\t\t\t\"zip\",\n\t\t\t\"tar\",\n\t\t\t\"gz\",\n\t\t\t\"rar\",\n\t\t\t\"7z\",\n\t\t\t\"jar\",\n\t\t\t\"war\",\n\t\t\t// Media files\n\t\t\t\"jpg\",\n\t\t\t\"jpeg\",\n\t\t\t\"png\",\n\t\t\t\"gif\",\n\t\t\t\"bmp\",\n\t\t\t\"ico\",\n\t\t\t\"tif\",\n\t\t\t\"tiff\",\n\t\t\t\"mp3\",\n\t\t\t\"mp4\",\n\t\t\t\"avi\",\n\t\t\t\"mov\",\n\t\t\t\"wmv\",\n\t\t\t\"flv\",\n\t\t\t\"wav\",\n\t\t\t\"ogg\",\n\t\t\t// Document formats\n\t\t\t\"pdf\",\n\t\t\t\"doc\",\n\t\t\t\"docx\",\n\t\t\t\"xls\",\n\t\t\t\"xlsx\",\n\t\t\t\"ppt\",\n\t\t\t\"pptx\",\n\t\t\t// Database files\n\t\t\t\"db\",\n\t\t\t\"sqlite\",\n\t\t\t\"mdb\",\n\t\t\t// Other binary formats\n\t\t\t\"class\",\n\t\t\t\"pyc\",\n\t\t\t\"pyd\",\n\t\t\t\"pyo\",\n\t\t\t\"woff\",\n\t\t\t\"woff2\",\n\t\t\t\"ttf\",\n\t\t\t\"otf\",\n\t\t];\n\n\t\treturn binaryExtensions.includes(ext);\n\t}\n\n\tasync start(returnResults = false) {\n\t\tif (this.displayStats) {\n\t\t\tperf.start();\n\t\t}\n\t\tawait this.scanFileSystem([this.path]);\n\t\tconst results = await this.postProcessResults(returnResults);\n\n\t\tif (this.displayStats) {\n\t\t\tperf.stop();\n\t\t\tprintStatistics({\n\t\t\t\tduration: perf.results.duration,\n\t\t\t\tgrep: this.grep,\n\t\t\t\tpattern: this.rePattern,\n\t\t\t\ttotalDirScanned: this.totalDirScanned,\n\t\t\t\ttotalDirsFound: this.totalDirFound,\n\t\t\t\ttotalFileScanned: this.totalFileScanned,\n\t\t\t\ttotalFilesFound: this.totalFileFound,\n\t\t\t\ttype: this.type,\n\t\t\t});\n\t\t}\n\t\treturn returnResults ? results : undefined;\n\t}\n\n\tasync scanFileSystem(nodes: string[]) {\n\t\tfor (const node of nodes) {\n\t\t\tlet result: boolean | RegExpExecArray,\n\t\t\t\tfiles: string[],\n\t\t\t\tshortname: string,\n\t\t\t\tstat: fs.Stats;\n\t\t\ttry {\n\t\t\t\tstat = await lstatAsync(node);\n\t\t\t} catch {\n\t\t\t\t// ignore read permission denied errors silently...\n\t\t\t}\n\n\t\t\tconst isDirectory = stat && stat.isDirectory();\n\t\t\tconst isFile = stat && stat.isFile();\n\n\t\t\t// Add this check to respect .gitignore patterns\n\t\t\tif (await this.shouldIgnoreByGitIgnore(node, isDirectory)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isDirectory && !this.shouldIgnoreFolder(node)) {\n\t\t\t\tthis.totalDirScanned++;\n\n\t\t\t\tresult = checkPattern(this.rePattern, node);\n\t\t\t\tif (result) {\n\t\t\t\t\tthis.totalDirFound++;\n\t\t\t\t\tthis.nodesList.push({\n\t\t\t\t\t\tcommand: this.command,\n\t\t\t\t\t\tmatch: result,\n\t\t\t\t\t\tname: node,\n\t\t\t\t\t\tstat,\n\t\t\t\t\t\ttype: STR_TYPE_DIRECTORY,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tfiles = await readdirAsync(node);\n\t\t\t\t\tawait this.scanFileSystem(\n\t\t\t\t\t\tfiles\n\t\t\t\t\t\t\t.filter((element) => this.filterHidden(element))\n\t\t\t\t\t\t\t.map(function (file) {\n\t\t\t\t\t\t\t\treturn join(node, file);\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t} catch {\n\t\t\t\t\t// nothing to declare\n\t\t\t\t}\n\t\t\t} else if (isFile) {\n\t\t\t\t// Skip files with ignored extensions\n\t\t\t\tif (this.shouldIgnoreFile(node)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tthis.totalFileScanned++;\n\t\t\t\tshortname = basename(node);\n\t\t\t\tconst patternResult = checkPattern(this.rePattern, shortname);\n\t\t\t\tif (patternResult) {\n\t\t\t\t\tthis.totalFileFound++;\n\t\t\t\t\tthis.nodesList.push({\n\t\t\t\t\t\tcommand: this.command,\n\t\t\t\t\t\tmatch: patternResult[0],\n\t\t\t\t\t\tname: node,\n\t\t\t\t\t\tstat,\n\t\t\t\t\t\ttype: STR_TYPE_FILE,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tasync readFileContent(filePath: string): Promise<string> {\n\t\ttry {\n\t\t\t// Check if it's a known binary extension\n\t\t\t/* istanbul ignore if */\n\t\t\tif (this.isBinaryFileExtension(filePath)) {\n\t\t\t\treturn \"[Binary file]\";\n\t\t\t}\n\t\t\tconst content = await readFileAsync(filePath, \"utf8\");\n\t\t\treturn content;\n\t\t} catch (error) {\n\t\t\t/* istanbul ignore next */\n\t\t\treturn `Error reading file: ${error.message}`;\n\t\t}\n\t}\n\n\tasync printFilesContent(returnResults: boolean) {\n\t\tconst fileNodes = this.nodesList.filter(\n\t\t\t(node) => node.type === STR_TYPE_FILE,\n\t\t);\n\n\t\tif (this.printMode === \"simple\") {\n\t\t\tfor (const node of fileNodes) {\n\t\t\t\tconst relativePath = relative(this.path, node.name);\n\t\t\t\tif (returnResults) {\n\t\t\t\t\tloggerInMemory.log(`---\\n./${relativePath}\\n---`);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.log(`---\\n./${relativePath}\\n---`);\n\t\t\t\t}\n\t\t\t\tconst content = await this.readFileContent(node.name);\n\t\t\t\tif (returnResults) {\n\t\t\t\t\tloggerInMemory.log(content);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.log(content);\n\t\t\t\t}\n\t\t\t\t// adding a new line after each file content except the last one\n\t\t\t\tif (node !== fileNodes[fileNodes.length - 1]) {\n\t\t\t\t\tif (returnResults) {\n\t\t\t\t\t\tloggerInMemory.log(\"\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.log(\"\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.printMode === \"xml\") {\n\t\t\tif (returnResults) {\n\t\t\t\tloggerInMemory.log(\"<documents>\");\n\t\t\t} else {\n\t\t\t\tlogger.log(\"<documents>\");\n\t\t\t}\n\n\t\t\tfor (let i = 0; i < fileNodes.length; i++) {\n\t\t\t\tconst node = fileNodes[i];\n\t\t\t\tconst relativePath = relative(this.path, node.name);\n\t\t\t\tconst content = await this.readFileContent(node.name);\n\n\t\t\t\tif (returnResults) {\n\t\t\t\t\tloggerInMemory.log(`<document index=\"${i + 1}\">`);\n\t\t\t\t\tloggerInMemory.log(`<source>./${relativePath}</source>`);\n\t\t\t\t\tloggerInMemory.log(\"<document_content>\");\n\t\t\t\t\tloggerInMemory.log(content);\n\t\t\t\t\tloggerInMemory.log(\"</document_content>\");\n\t\t\t\t\tloggerInMemory.log(\"</document>\");\n\t\t\t\t} else {\n\t\t\t\t\tlogger.log(`<document index=\"${i + 1}\">`);\n\t\t\t\t\tlogger.log(`<source>./${relativePath}</source>`);\n\t\t\t\t\tlogger.log(\"<document_content>\");\n\t\t\t\t\tlogger.log(content);\n\t\t\t\t\tlogger.log(\"</document_content>\");\n\t\t\t\t\tlogger.log(\"</document>\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (returnResults) {\n\t\t\t\tloggerInMemory.log(\"</documents>\");\n\t\t\t} else {\n\t\t\t\tlogger.log(\"</documents>\");\n\t\t\t}\n\t\t}\n\t\tconst results = returnResults ? loggerInMemory.getMemoryLogs() : undefined;\n\t\tloggerInMemory.clearMemoryLogs();\n\t\treturn results;\n\t}\n\n\tasync shouldIgnoreByGitIgnore(\n\t\tnodePath: string,\n\t\tisDirectory: boolean,\n\t): Promise<boolean> {\n\t\t/* istanbul ignore if */\n\t\tif (this.ignoreGitIgnore) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.gitIgnoreHandler.isIgnored(nodePath, isDirectory);\n\t}\n\n\tasync postProcessResults(returnResults: boolean) {\n\t\tif (this.grep) {\n\t\t\t/**\n\t\t\t * Resetting the number of files found, since we want to\n\t\t\t * show how many matched the grep, not how many matched the\n\t\t\t * pattern (in the file name).\n\t\t\t */\n\t\t\tthis.totalFileFound = 0;\n\t\t}\n\n\t\t// If printMode is enabled, handle file content printing and return\n\t\tif (this.printMode && [\"simple\", \"xml\"].includes(this.printMode)) {\n\t\t\treturn await this.printFilesContent(returnResults);\n\t\t}\n\n\t\t/* istanbul ignore if */\n\t\tif (!this.boring) {\n\t\t\tlogger.log();\n\t\t}\n\n\t\tfor (const node of this.nodesList) {\n\t\t\tif (\n\t\t\t\t(this.type === STR_TYPE_FILE && node.type === STR_TYPE_FILE) ||\n\t\t\t\t(this.type === STR_TYPE_DIRECTORY &&\n\t\t\t\t\tnode.type === STR_TYPE_DIRECTORY) ||\n\t\t\t\tthis.type === STR_TYPE_BOTH\n\t\t\t) {\n\t\t\t\tlet list: {\n\t\t\t\t\t\tgroup?: string;\n\t\t\t\t\t\tmdate?: string;\n\t\t\t\t\t\tmode?: string;\n\t\t\t\t\t\towner?: string;\n\t\t\t\t\t\tsize?: string;\n\t\t\t\t\t} = {\n\t\t\t\t\t\tgroup: \"\",\n\t\t\t\t\t\tmdate: \"\",\n\t\t\t\t\t\tmode: \"\",\n\t\t\t\t\t\towner: \"\",\n\t\t\t\t\t\tsize: \"\",\n\t\t\t\t\t},\n\t\t\t\t\tname: string,\n\t\t\t\t\tseparator: string = \"\";\n\n\t\t\t\t/* istanbul ignore if */\n\t\t\t\tif (this.displayLongListing) {\n\t\t\t\t\tlist = await formatLongListings(node.stat, node.type);\n\t\t\t\t\tseparator = \"\\t\";\n\t\t\t\t}\n\n\t\t\t\tconst color = node.type === STR_TYPE_FILE ? kleur.gray : kleur.blue;\n\t\t\t\tname = relative(this.path, node.name);\n\n\t\t\t\tif (node.match) {\n\t\t\t\t\tconst matchStr = String(node.match); // Ensure match is a string\n\t\t\t\t\tconst match = new RegExp(matchStr, \"g\");\n\t\t\t\t\tconst highlightedMatch = kleur.black().bgYellow(matchStr);\n\t\t\t\t\tname = color(name.replace(match, highlightedMatch));\n\t\t\t\t} else {\n\t\t\t\t\tname = color(name);\n\t\t\t\t}\n\n\t\t\t\tif (this.grep && node.type === STR_TYPE_FILE) {\n\t\t\t\t\tconst { totalMatchingLines, results } = await runGrepOnNode(\n\t\t\t\t\t\tnode.name,\n\t\t\t\t\t\tthis.grep,\n\t\t\t\t\t);\n\t\t\t\t\t/* istanbul ignore else */\n\t\t\t\t\tif (totalMatchingLines) {\n\t\t\t\t\t\tthis.totalFileFound++;\n\t\t\t\t\t\tconst occurrences = plur(\"occurrence\", totalMatchingLines);\n\n\t\t\t\t\t\tlogger.log(\n\t\t\t\t\t\t\t` %s${separator}%s${separator}%s${separator}%s${separator}%s`,\n\t\t\t\t\t\t\tlist.mode.trim(),\n\t\t\t\t\t\t\tlist.owner.trim(),\n\t\t\t\t\t\t\tlist.size.trim(),\n\t\t\t\t\t\t\tlist.mdate,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t`(${kleur.white(totalMatchingLines)} ${occurrences})`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlogger.log(`${results.join(\"\\n\")}\\n`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t/* istanbul ignore next */\n\t\t\t\t\tif (!this.grep) {\n\t\t\t\t\t\tlogger.log(\n\t\t\t\t\t\t\t` %s${separator}%s${separator}%s${separator}%s${separator}%s`,\n\t\t\t\t\t\t\tlist.mode.trim(),\n\t\t\t\t\t\t\tlist.owner.trim(),\n\t\t\t\t\t\t\tlist.size.trim(),\n\t\t\t\t\t\t\tlist.mdate,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (node.command) {\n\t\t\t\t\t\t\tawait runCommandOnNode(node.name, node.command);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["basename","extname","join","relative","GitIgnoreHandler","STR_TYPE_BOTH","STR_TYPE_DIRECTORY","STR_TYPE_FILE","checkPattern","formatLongListings","printStatistics","runCommandOnNode","runGrepOnNode","promisify","Logger","Performance","fs","kleur","plur","lstatAsync","lstat","readdirAsync","readdir","readFileAsync","readFile","perf","logger","boring","process","env","NODE_ENV","loggerInMemory","inMemory","Search","command","displayHiddenFilesAndFolders","displayLongListing","displayStats","grep","nodesList","path","rePattern","totalDirFound","totalDirScanned","totalFileFound","totalFileScanned","type","ignoreExtensions","ignoreFiles","ignoreFolders","printMode","gitIgnoreHandler","ignoreGitIgnore","constructor","dot","ignoreCase","short","pattern","stats","ignoreExtension","ignoreFile","ignoreFolder","RegExp","undefined","enabled","trim","map","ext","toLowerCase","error","exit","shouldIgnoreFolder","directory","folderName","includes","shouldIgnoreFile","filePath","filename","length","extension","replace","endsWith","filterHidden","value","isBinaryFileExtension","binaryExtensions","start","returnResults","scanFileSystem","results","postProcessResults","stop","duration","totalDirsFound","totalFilesFound","nodes","node","result","files","shortname","stat","isDirectory","isFile","shouldIgnoreByGitIgnore","push","match","name","filter","element","file","patternResult","readFileContent","content","message","printFilesContent","fileNodes","relativePath","log","i","getMemoryLogs","clearMemoryLogs","nodePath","isIgnored","list","group","mdate","mode","owner","size","separator","color","gray","blue","matchStr","String","highlightedMatch","black","bgYellow","totalMatchingLines","occurrences","white"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,YAAY;AAE9D,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SACCC,aAAa,EACbC,kBAAkB,EAClBC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,QACP,iBAAiB;AAExB,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,UAAU,OAAO;AAExB,MAAMC,aAAaN,UAAUG,GAAGI,KAAK;AACrC,MAAMC,eAAeR,UAAUG,GAAGM,OAAO;AACzC,MAAMC,gBAAgBV,UAAUG,GAAGQ,QAA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oBACrC;gBACD,OAAO;oBACN,wBAAwB,GACxB,IAAI,CAAC,IAAI,CAACoC,IAAI,EAAE;wBACfZ,OAAO2F,GAAG,CACT,CAAC,GAAG,EAAEY,UAAU,EAAE,EAAEA,UAAU,EAAE,EAAEA,UAAU,EAAE,EAAEA,UAAU,EAAE,CAAC,EAC7DN,KAAKG,IAAI,CAAC7D,IAAI,IACd0D,KAAKI,KAAK,CAAC9D,IAAI,IACf0D,KAAKK,IAAI,CAAC/D,IAAI,IACd0D,KAAKE,KAAK,EACVnB;wBAED,IAAIV,KAAK9D,OAAO,EAAE;4BACjB,MAAMvB,iBAAiBqF,KAAKU,IAAI,EAAEV,KAAK9D,OAAO;wBAC/C;oBACD;gBACD;YACD;QACD;IACD;AACD"}
@@ -4,7 +4,6 @@ export declare const defaultFlags: {
4
4
  ignoreCase: boolean;
5
5
  short: boolean;
6
6
  stats: boolean;
7
- ignoreExtension: any[];
8
7
  ignoreGitIgnore: boolean;
9
8
  };
10
9
  export declare const defaultParameters: {
package/dist/defaults.js CHANGED
@@ -4,7 +4,6 @@ export const defaultFlags = {
4
4
  ignoreCase: false,
5
5
  short: false,
6
6
  stats: false,
7
- ignoreExtension: [],
8
7
  ignoreGitIgnore: false
9
8
  };
10
9
  export const defaultParameters = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const defaultFlags = {\n\tboring: false,\n\tdot: false,\n\tignoreCase: false,\n\tshort: false,\n\tstats: false,\n\tignoreExtension: [],\n\tignoreGitIgnore: false,\n};\n\nexport const defaultParameters = {\n\t\"0\": process.cwd(),\n};\n"],"names":["defaultFlags","boring","dot","ignoreCase","short","stats","ignoreExtension","ignoreGitIgnore","defaultParameters","process","cwd"],"mappings":"AAAA,OAAO,MAAMA,eAAe;IAC3BC,QAAQ;IACRC,KAAK;IACLC,YAAY;IACZC,OAAO;IACPC,OAAO;IACPC,iBAAiB,EAAE;IACnBC,iBAAiB;AAClB,EAAE;AAEF,OAAO,MAAMC,oBAAoB;IAChC,KAAKC,QAAQC,GAAG;AACjB,EAAE"}
1
+ {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const defaultFlags = {\n\tboring: false,\n\tdot: false,\n\tignoreCase: false,\n\tshort: false,\n\tstats: false,\n\tignoreGitIgnore: false,\n};\n\nexport const defaultParameters = {\n\t\"0\": process.cwd(),\n};\n"],"names":["defaultFlags","boring","dot","ignoreCase","short","stats","ignoreGitIgnore","defaultParameters","process","cwd"],"mappings":"AAAA,OAAO,MAAMA,eAAe;IAC3BC,QAAQ;IACRC,KAAK;IACLC,YAAY;IACZC,OAAO;IACPC,OAAO;IACPC,iBAAiB;AAClB,EAAE;AAEF,OAAO,MAAMC,oBAAoB;IAChC,KAAKC,QAAQC,GAAG;AACjB,EAAE"}
package/dist/parse.js CHANGED
@@ -78,13 +78,19 @@ import { parser } from "@node-cli/parser";
78
78
  },
79
79
  ignoreExtension: {
80
80
  shortFlag: "I",
81
- description: "Ignore files extensions",
81
+ description: "Ignore files extension, can be used multiple times",
82
82
  type: "string",
83
83
  isMultiple: true
84
84
  },
85
85
  ignoreFile: {
86
86
  shortFlag: "F",
87
- description: "Ignore files names",
87
+ description: "Ignore files name, can be used multiple times",
88
+ type: "string",
89
+ isMultiple: true
90
+ },
91
+ ignoreFolder: {
92
+ shortFlag: "D",
93
+ description: "Ignore folders name, can be used multiple times",
88
94
  type: "string",
89
95
  isMultiple: true
90
96
  },
package/dist/parse.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/parse.ts"],"sourcesContent":["import { defaultFlags, defaultParameters } from \"./defaults.js\";\n\nimport { parser } from \"@node-cli/parser\";\n\nexport type Flags = {\n\tboring?: boolean;\n\tdot?: boolean;\n\tignoreCase?: boolean;\n\tshort?: boolean;\n\tstats?: boolean;\n\tgrep?: string;\n\ttype?: string;\n\tignore?: string[];\n\tprintMode?: string;\n};\n\nexport type Parameters = {\n\tpath?: string;\n};\n\nexport type Configuration = {\n\tflags?: Flags;\n\tparameters?: Parameters;\n};\n\n/* istanbul ignore next */\nexport const config: Configuration = parser({\n\tmeta: import.meta,\n\texamples: [\n\t\t{\n\t\t\tcommand: 'search --type f --pattern \".jsx$\" src/',\n\t\t\tcomment:\n\t\t\t\t'## Find all files with the extension \".jsx\" in the \"src\" folder',\n\t\t},\n\t\t{\n\t\t\tcommand: 'search --type f --pattern \".sh$\" --command \"chmod +x\" bin/',\n\t\t\tcomment: `## Change the permissions to executable for all the files with\\n ## the extension \".sh\" found under the \"bin\" folder`,\n\t\t},\n\t\t{\n\t\t\tcommand: 'search --type f --pattern \".md$\" --grep \"Table of Content\"',\n\t\t\tcomment: `## Search in all the markdown files under the \"src\" folder for\\n ## the keywords \"Table of Content\"`,\n\t\t},\n\t],\n\tflags: {\n\t\tboring: {\n\t\t\tshortFlag: \"b\",\n\t\t\tdefault: defaultFlags.boring,\n\t\t\tdescription: \"Do not use color output\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tcommand: {\n\t\t\tshortFlag: \"c\",\n\t\t\tdescription: \"Command to execute over each node (ex: chmod +x)\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tdot: {\n\t\t\tdefault: defaultFlags.dot,\n\t\t\tdescription: \"Show hidden files and directories\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tgrep: {\n\t\t\tshortFlag: \"g\",\n\t\t\tdescription: \"A RegExp to match the content of the files found\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\thelp: {\n\t\t\tshortFlag: \"h\",\n\t\t\tdescription: \"Display help instructions\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tignoreCase: {\n\t\t\tshortFlag: \"i\",\n\t\t\tdefault: defaultFlags.ignoreCase,\n\t\t\tdescription: \"Ignore case when searching\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tpattern: {\n\t\t\tshortFlag: \"p\",\n\t\t\tdescription: \"A regular expression to match file or folder names\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tshort: {\n\t\t\tdefault: defaultFlags.short,\n\t\t\tdescription: \"Short listing format (equivalent to ls)\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tstats: {\n\t\t\tshortFlag: \"s\",\n\t\t\tdefault: defaultFlags.stats,\n\t\t\tdescription: \"Display some statistics\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\ttype: {\n\t\t\tshortFlag: \"t\",\n\t\t\tdefault: \"both\",\n\t\t\tdescription: \"Search for files (f) or directories (d)\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tversion: {\n\t\t\tshortFlag: \"v\",\n\t\t\tdescription: \"Output the current version\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tignoreExtension: {\n\t\t\tshortFlag: \"I\",\n\t\t\tdescription: \"Ignore files extensions\",\n\t\t\ttype: \"string\",\n\t\t\tisMultiple: true,\n\t\t},\n\t\tignoreFile: {\n\t\t\tshortFlag: \"F\",\n\t\t\tdescription: \"Ignore files names\",\n\t\t\ttype: \"string\",\n\t\t\tisMultiple: true,\n\t\t},\n\t\tprintMode: {\n\t\t\tshortFlag: \"P\",\n\t\t\tdescription: \"Print mode (simple or xml)\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tignoreGitIgnore: {\n\t\t\tdescription: \"Ignore .gitignore files\",\n\t\t\tdefault: defaultFlags.ignoreGitIgnore,\n\t\t\ttype: \"boolean\",\n\t\t},\n\t},\n\tparameters: {\n\t\tpath: {\n\t\t\tdefault: \"current folder\",\n\t\t\tdescription: \"the path where to start the search\",\n\t\t},\n\t},\n\tusage: \"search [options] [path]\",\n\tdefaultFlags,\n\tdefaultParameters,\n});\n"],"names":["defaultFlags","defaultParameters","parser","config","meta","examples","command","comment","flags","boring","shortFlag","default","description","type","dot","grep","help","ignoreCase","pattern","short","stats","version","ignoreExtension","isMultiple","ignoreFile","printMode","ignoreGitIgnore","parameters","path","usage"],"mappings":"AAAA,SAASA,YAAY,EAAEC,iBAAiB,QAAQ,gBAAgB;AAEhE,SAASC,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;IACAc,YAAY;QACXC,MAAM;YACLjB,SAAS;YACTC,aAAa;QACd;IACD;IACAiB,OAAO;IACP7B;IACAC;AACD,GAAG"}
1
+ {"version":3,"sources":["../src/parse.ts"],"sourcesContent":["import { defaultFlags, defaultParameters } from \"./defaults.js\";\n\nimport { parser } from \"@node-cli/parser\";\n\nexport type Flags = {\n\tboring?: boolean;\n\tdot?: boolean;\n\tignoreCase?: boolean;\n\tshort?: boolean;\n\tstats?: boolean;\n\tgrep?: string;\n\ttype?: string;\n\tignore?: string[];\n\tprintMode?: string;\n};\n\nexport type Parameters = {\n\tpath?: string;\n};\n\nexport type Configuration = {\n\tflags?: Flags;\n\tparameters?: Parameters;\n};\n\n/* istanbul ignore next */\nexport const config: Configuration = parser({\n\tmeta: import.meta,\n\texamples: [\n\t\t{\n\t\t\tcommand: 'search --type f --pattern \".jsx$\" src/',\n\t\t\tcomment:\n\t\t\t\t'## Find all files with the extension \".jsx\" in the \"src\" folder',\n\t\t},\n\t\t{\n\t\t\tcommand: 'search --type f --pattern \".sh$\" --command \"chmod +x\" bin/',\n\t\t\tcomment: `## Change the permissions to executable for all the files with\\n ## the extension \".sh\" found under the \"bin\" folder`,\n\t\t},\n\t\t{\n\t\t\tcommand: 'search --type f --pattern \".md$\" --grep \"Table of Content\"',\n\t\t\tcomment: `## Search in all the markdown files under the \"src\" folder for\\n ## the keywords \"Table of Content\"`,\n\t\t},\n\t],\n\tflags: {\n\t\tboring: {\n\t\t\tshortFlag: \"b\",\n\t\t\tdefault: defaultFlags.boring,\n\t\t\tdescription: \"Do not use color output\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tcommand: {\n\t\t\tshortFlag: \"c\",\n\t\t\tdescription: \"Command to execute over each node (ex: chmod +x)\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tdot: {\n\t\t\tdefault: defaultFlags.dot,\n\t\t\tdescription: \"Show hidden files and directories\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tgrep: {\n\t\t\tshortFlag: \"g\",\n\t\t\tdescription: \"A RegExp to match the content of the files found\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\thelp: {\n\t\t\tshortFlag: \"h\",\n\t\t\tdescription: \"Display help instructions\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tignoreCase: {\n\t\t\tshortFlag: \"i\",\n\t\t\tdefault: defaultFlags.ignoreCase,\n\t\t\tdescription: \"Ignore case when searching\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tpattern: {\n\t\t\tshortFlag: \"p\",\n\t\t\tdescription: \"A regular expression to match file or folder names\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tshort: {\n\t\t\tdefault: defaultFlags.short,\n\t\t\tdescription: \"Short listing format (equivalent to ls)\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tstats: {\n\t\t\tshortFlag: \"s\",\n\t\t\tdefault: defaultFlags.stats,\n\t\t\tdescription: \"Display some statistics\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\ttype: {\n\t\t\tshortFlag: \"t\",\n\t\t\tdefault: \"both\",\n\t\t\tdescription: \"Search for files (f) or directories (d)\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tversion: {\n\t\t\tshortFlag: \"v\",\n\t\t\tdescription: \"Output the current version\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tignoreExtension: {\n\t\t\tshortFlag: \"I\",\n\t\t\tdescription: \"Ignore files extension, can be used multiple times\",\n\t\t\ttype: \"string\",\n\t\t\tisMultiple: true,\n\t\t},\n\t\tignoreFile: {\n\t\t\tshortFlag: \"F\",\n\t\t\tdescription: \"Ignore files name, can be used multiple times\",\n\t\t\ttype: \"string\",\n\t\t\tisMultiple: true,\n\t\t},\n\t\tignoreFolder: {\n\t\t\tshortFlag: \"D\",\n\t\t\tdescription: \"Ignore folders name, can be used multiple times\",\n\t\t\ttype: \"string\",\n\t\t\tisMultiple: true,\n\t\t},\n\t\tprintMode: {\n\t\t\tshortFlag: \"P\",\n\t\t\tdescription: \"Print mode (simple or xml)\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tignoreGitIgnore: {\n\t\t\tdescription: \"Ignore .gitignore files\",\n\t\t\tdefault: defaultFlags.ignoreGitIgnore,\n\t\t\ttype: \"boolean\",\n\t\t},\n\t},\n\tparameters: {\n\t\tpath: {\n\t\t\tdefault: \"current folder\",\n\t\t\tdescription: \"the path where to start the search\",\n\t\t},\n\t},\n\tusage: \"search [options] [path]\",\n\tdefaultFlags,\n\tdefaultParameters,\n});\n"],"names":["defaultFlags","defaultParameters","parser","config","meta","examples","command","comment","flags","boring","shortFlag","default","description","type","dot","grep","help","ignoreCase","pattern","short","stats","version","ignoreExtension","isMultiple","ignoreFile","ignoreFolder","printMode","ignoreGitIgnore","parameters","path","usage"],"mappings":"AAAA,SAASA,YAAY,EAAEC,iBAAiB,QAAQ,gBAAgB;AAEhE,SAASC,MAAM,QAAQ,mBAAmB;AAuB1C,wBAAwB,GACxB,OAAO,MAAMC,SAAwBD,OAAO;IAC3CE,MAAM;IACNC,UAAU;QACT;YACCC,SAAS;YACTC,SACC;QACF;QACA;YACCD,SAAS;YACTC,SAAS,CAAC,uHAAuH,CAAC;QACnI;QACA;YACCD,SAAS;YACTC,SAAS,CAAC,sGAAsG,CAAC;QAClH;KACA;IACDC,OAAO;QACNC,QAAQ;YACPC,WAAW;YACXC,SAASX,aAAaS,MAAM;YAC5BG,aAAa;YACbC,MAAM;QACP;QACAP,SAAS;YACRI,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;QACAC,KAAK;YACJH,SAASX,aAAac,GAAG;YACzBF,aAAa;YACbC,MAAM;QACP;QACAE,MAAM;YACLL,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;QACAG,MAAM;YACLN,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;QACAI,YAAY;YACXP,WAAW;YACXC,SAASX,aAAaiB,UAAU;YAChCL,aAAa;YACbC,MAAM;QACP;QACAK,SAAS;YACRR,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;QACAM,OAAO;YACNR,SAASX,aAAamB,KAAK;YAC3BP,aAAa;YACbC,MAAM;QACP;QACAO,OAAO;YACNV,WAAW;YACXC,SAASX,aAAaoB,KAAK;YAC3BR,aAAa;YACbC,MAAM;QACP;QACAA,MAAM;YACLH,WAAW;YACXC,SAAS;YACTC,aAAa;YACbC,MAAM;QACP;QACAQ,SAAS;YACRX,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;QACAS,iBAAiB;YAChBZ,WAAW;YACXE,aAAa;YACbC,MAAM;YACNU,YAAY;QACb;QACAC,YAAY;YACXd,WAAW;YACXE,aAAa;YACbC,MAAM;YACNU,YAAY;QACb;QACAE,cAAc;YACbf,WAAW;YACXE,aAAa;YACbC,MAAM;YACNU,YAAY;QACb;QACAG,WAAW;YACVhB,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;QACAc,iBAAiB;YAChBf,aAAa;YACbD,SAASX,aAAa2B,eAAe;YACrCd,MAAM;QACP;IACD;IACAe,YAAY;QACXC,MAAM;YACLlB,SAAS;YACTC,aAAa;QACd;IACD;IACAkB,OAAO;IACP9B;IACAC;AACD,GAAG"}
package/dist/search.js CHANGED
@@ -24,8 +24,7 @@ if (config.flags.grep) {
24
24
  }
25
25
  const search = new Search({
26
26
  ...config.flags,
27
- path: customPath,
28
- foldersBlacklist: /node_modules/gi
27
+ path: customPath
29
28
  });
30
29
  await search.start();
31
30
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/search.ts"],"sourcesContent":["#!/usr/bin/env node\n/* istanbul ignore file */\n\nimport path from \"node:path\";\nimport { Logger } from \"@node-cli/logger\";\nimport fs from \"fs-extra\";\nimport { Search } from \"./core.js\";\nimport { config } from \"./parse.js\";\nimport { STR_TYPE_FILE } from \"./utilities.js\";\n\nconst logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\n\nlet customPath = config.parameters[0];\nif (fs.pathExistsSync(customPath)) {\n\tcustomPath = path.resolve(customPath);\n} else {\n\tlogger.printErrorsAndExit([`Folder ${customPath} does not exist!`], 0);\n}\n\nif (config.flags.grep) {\n\t// forcing simplified display if grep is true.\n\tconfig.flags.short = true;\n\t// And forcing type to files\n\tconfig.flags.type = STR_TYPE_FILE;\n}\n\nconst search = new Search({\n\t...config.flags,\n\tpath: customPath,\n\tfoldersBlacklist: /node_modules/gi,\n});\n\nawait search.start();\n"],"names":["path","Logger","fs","Search","config","STR_TYPE_FILE","logger","boring","process","env","NODE_ENV","customPath","parameters","pathExistsSync","resolve","printErrorsAndExit","flags","grep","short","type","search","foldersBlacklist","start"],"mappings":";AACA,wBAAwB,GAExB,OAAOA,UAAU,YAAY;AAC7B,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,QAAQ,WAAW;AAC1B,SAASC,MAAM,QAAQ,YAAY;AACnC,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,MAAMC,SAAS,IAAIL,OAAO;IACzBM,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK;AAClC;AAEA,IAAIC,aAAaP,OAAOQ,UAAU,CAAC,EAAE;AACrC,IAAIV,GAAGW,cAAc,CAACF,aAAa;IAClCA,aAAaX,KAAKc,OAAO,CAACH;AAC3B,OAAO;IACNL,OAAOS,kBAAkB,CAAC;QAAC,CAAC,OAAO,EAAEJ,WAAW,gBAAgB,CAAC;KAAC,EAAE;AACrE;AAEA,IAAIP,OAAOY,KAAK,CAACC,IAAI,EAAE;IACtB,8CAA8C;IAC9Cb,OAAOY,KAAK,CAACE,KAAK,GAAG;IACrB,4BAA4B;IAC5Bd,OAAOY,KAAK,CAACG,IAAI,GAAGd;AACrB;AAEA,MAAMe,SAAS,IAAIjB,OAAO;IACzB,GAAGC,OAAOY,KAAK;IACfhB,MAAMW;IACNU,kBAAkB;AACnB;AAEA,MAAMD,OAAOE,KAAK"}
1
+ {"version":3,"sources":["../src/search.ts"],"sourcesContent":["#!/usr/bin/env node\n/* istanbul ignore file */\n\nimport path from \"node:path\";\nimport { Logger } from \"@node-cli/logger\";\nimport fs from \"fs-extra\";\nimport { Search } from \"./core.js\";\nimport { config } from \"./parse.js\";\nimport { STR_TYPE_FILE } from \"./utilities.js\";\n\nconst logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\n\nlet customPath = config.parameters[0];\nif (fs.pathExistsSync(customPath)) {\n\tcustomPath = path.resolve(customPath);\n} else {\n\tlogger.printErrorsAndExit([`Folder ${customPath} does not exist!`], 0);\n}\n\nif (config.flags.grep) {\n\t// forcing simplified display if grep is true.\n\tconfig.flags.short = true;\n\t// And forcing type to files\n\tconfig.flags.type = STR_TYPE_FILE;\n}\n\nconst search = new Search({\n\t...config.flags,\n\tpath: customPath,\n});\n\nawait search.start();\n"],"names":["path","Logger","fs","Search","config","STR_TYPE_FILE","logger","boring","process","env","NODE_ENV","customPath","parameters","pathExistsSync","resolve","printErrorsAndExit","flags","grep","short","type","search","start"],"mappings":";AACA,wBAAwB,GAExB,OAAOA,UAAU,YAAY;AAC7B,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,QAAQ,WAAW;AAC1B,SAASC,MAAM,QAAQ,YAAY;AACnC,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,MAAMC,SAAS,IAAIL,OAAO;IACzBM,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK;AAClC;AAEA,IAAIC,aAAaP,OAAOQ,UAAU,CAAC,EAAE;AACrC,IAAIV,GAAGW,cAAc,CAACF,aAAa;IAClCA,aAAaX,KAAKc,OAAO,CAACH;AAC3B,OAAO;IACNL,OAAOS,kBAAkB,CAAC;QAAC,CAAC,OAAO,EAAEJ,WAAW,gBAAgB,CAAC;KAAC,EAAE;AACrE;AAEA,IAAIP,OAAOY,KAAK,CAACC,IAAI,EAAE;IACtB,8CAA8C;IAC9Cb,OAAOY,KAAK,CAACE,KAAK,GAAG;IACrB,4BAA4B;IAC5Bd,OAAOY,KAAK,CAACG,IAAI,GAAGd;AACrB;AAEA,MAAMe,SAAS,IAAIjB,OAAO;IACzB,GAAGC,OAAOY,KAAK;IACfhB,MAAMW;AACP;AAEA,MAAMS,OAAOC,KAAK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-cli/search",
3
- "version": "2.0.1",
3
+ "version": "3.0.1",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "description": "Search for files in a directory",
@@ -25,7 +25,7 @@
25
25
  "watch": "swc --strip-leading-paths --watch --out-dir dist src"
26
26
  },
27
27
  "dependencies": {
28
- "@node-cli/logger": "1.2.6",
28
+ "@node-cli/logger": "1.3.0",
29
29
  "@node-cli/parser": "2.4.0",
30
30
  "@node-cli/perf": "1.0.6",
31
31
  "@node-cli/run": "1.1.2",
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "cb53d5ca5c0df89eea2b004ded48b41b3178bc34"
41
+ "gitHead": "e2e960f6c779f5069efaf294bb8067de1e325dc1"
42
42
  }