@sujithx1/optimizeguard 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/scanner.ts +30 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sujithx1/optimizeguard",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
 
6
6
  "bin": {
package/src/scanner.ts CHANGED
@@ -1,5 +1,32 @@
1
- import {glob} from "glob";
2
1
 
3
- export async function scanProject() {
4
- return glob.sync("**/*.{ts,js}", { ignore: ["node_modules/**", "dist/**"] });
2
+ import { readdir } from "node:fs/promises";
3
+ import path from "node:path";
4
+
5
+ const IGNORE = new Set([
6
+ "node_modules",
7
+ "dist",
8
+ "build",
9
+ ".git",
10
+ ".next",
11
+ ".turbo"
12
+ ]);
13
+
14
+ export async function scanProject(dir = process.cwd(), files: string[] = []) {
15
+ const entries = await readdir(dir, { withFileTypes: true });
16
+
17
+ await Promise.all(
18
+ entries.map(async (entry) => {
19
+ if (IGNORE.has(entry.name)) return;
20
+
21
+ const fullPath = path.join(dir, entry.name);
22
+
23
+ if (entry.isDirectory()) {
24
+ await scanProject(fullPath, files);
25
+ } else if (entry.name.endsWith(".ts")) {
26
+ files.push(fullPath);
27
+ }
28
+ })
29
+ );
30
+
31
+ return files;
5
32
  }