-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-docs.js
25 lines (23 loc) · 977 Bytes
/
4-docs.js
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
const fs = require('fs')
async function main() {
let since = fs.readFileSync("./since.txt", "ascii").split("\n").filter(v=>!!v)
for (let row of since) {
let [method,version] = row.split(",")
if (!method.startsWith("faker.locales.")
&& !method.startsWith("faker._locale")
&& !method.endsWith(".faker")
&& method.split(".").length==3) {
let [faker,mod,methodname] = method.split(".")
let file = `../faker/src/modules/${mod}/index.ts`
let data = fs.readFileSync(file, "utf-8")
let regex = new RegExp(` ${methodname}[<(]`)
const index = data.match(regex)?.index
if (index) {
const endOfComment = data.lastIndexOf("*/", index)-2
const newData = data.slice(0,endOfComment)+` * @since ${version}\n`+data.slice(endOfComment-1)
fs.writeFileSync(file, newData)
}
}
}
}
main()