@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.
- package/package.json +1 -1
- package/src/scanner.ts +30 -3
package/package.json
CHANGED
package/src/scanner.ts
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
|
-
import {glob} from "glob";
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
|
|
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
|
}
|