Skip to content

Commit a37f9d6

Browse files
committed
refactor: move cli logic into core
1 parent 4cd6ff8 commit a37f9d6

File tree

3 files changed

+30
-32
lines changed

3 files changed

+30
-32
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,6 @@ dist
129129
.yarn/install-state.gz
130130
.pnp.*
131131

132-
# OS files
132+
# Others
133133
.DS_Store
134+
.turbo

esonar/src/index.ts

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,7 @@
1-
import type { Item } from "@esonar/core";
2-
import { parse, scan } from "@esonar/core";
3-
import { readFileSync } from "fs";
1+
import { esonar } from "@esonar/core";
42

53
const main = async () => {
6-
const projects = scan();
7-
const items: Item[] = [];
8-
9-
for (const project of projects) {
10-
for (const file of project.files) {
11-
const content = readFileSync(file, "utf-8");
12-
const module = project.metadata.name;
13-
14-
// console.log(
15-
// file,
16-
// await parse(content, {
17-
// file,
18-
// module,
19-
// }),
20-
// );
21-
22-
items.push(
23-
...(await parse(content, {
24-
file,
25-
module,
26-
})),
27-
);
28-
}
29-
}
30-
31-
console.log(items);
4+
await esonar();
325
};
336

347
main().catch((error) => {

packages/core/src/index.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
1-
export * from "./parser";
2-
export * from "./scanner";
1+
import { readFileSync } from "fs";
2+
3+
import { scan } from "./scanner";
4+
import type { Item } from "./entities/item";
5+
import { parse } from "./parser";
6+
7+
export const esonar = async () => {
8+
const projects = scan();
9+
const items: Item[] = [];
10+
11+
for (const project of projects) {
12+
for (const file of project.files) {
13+
const content = readFileSync(file, "utf-8");
14+
const module = project.metadata.name;
15+
16+
const projectItems = await parse(content, {
17+
file,
18+
module,
19+
});
20+
21+
items.push(...projectItems);
22+
}
23+
}
24+
25+
console.log(items);
26+
};

0 commit comments

Comments
 (0)