-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.mjs
33 lines (28 loc) · 916 Bytes
/
index.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env node
import { countFiles } from "./count-files.mjs";
import { listFiles } from "./get-file-list.mjs";
const action = process.argv[2];
const startingDir = process.argv[3];
if (startingDir === undefined) {
console.log("No path provided");
console.log("Example call: extension-analyzer ~/project/example jsx? tsx?");
process.exit(-1);
}
if (action === "--count") {
const extensionsArg = process.argv.splice(4);
if (extensionsArg.length === 0) {
console.log("No extensions provided");
console.log("Example call: extension-analyzer ~/project/example jsx? tsx?");
process.exit(-1);
}
const extensions = extensionsArg.map((ext) => ({
name: ext,
regex: new RegExp(`(\\.${ext})$`),
}));
countFiles(startingDir, extensions);
}
if (action === "--list") {
const extension = process.argv[4];
const team = process.argv[5];
listFiles(startingDir, extension, team);
}