-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
32 lines (24 loc) · 823 Bytes
/
main.ts
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
const fs = require("fs");
const path = require("path");
import {
getDocsList,
IFDocsItem,
genReadmeMd,
removeSpecifiedDirs,
} from "./utils/index";
const docsList = getDocsList(path.resolve(__dirname, "docs")).sort(
(a: IFDocsItem, b: IFDocsItem) => -a.createTimeMs + b.createTimeMs
);
const readmeMd = genReadmeMd(docsList);
console.log(readmeMd);
const readmeStr = fs.readFileSync(path.resolve(__dirname, "README.md"), "utf8");
fs.writeFileSync(
path.resolve(__dirname, "README.md"),
readmeStr.substring(0, readmeStr.indexOf("## 目录") + 5) + "\n\r" + readmeMd
);
console.log("The name of 《Readme.md》 file was successfully created!");
removeSpecifiedDirs([
path.resolve(__dirname, "./"),
path.resolve(__dirname, "./utils"),
]);
console.log("The cache of files was successfully deleted!");