-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypedoc.ts
30 lines (27 loc) · 945 Bytes
/
typedoc.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
import { fileURLToPath } from 'url'
import fsPromises from 'fs/promises'
import JSON5 from 'json5'
import path from 'path'
const __dirname = path.dirname(fileURLToPath(import.meta.url)) // eslint-disable-line @typescript-eslint/naming-convention
async function main (): Promise<void> {
// version in package.json
const pkg = JSON5.parse<{ version: string }>(await fsPromises.readFile(path.resolve(__dirname, './package.json'), 'utf8'))
const verFiles = [
'./dist/variables/index.version.html',
]
for (let file of verFiles) {
try {
file = path.resolve(__dirname, file)
let content = await fsPromises.readFile(file, 'utf8')
content = content.replace(/pkg.version/g, pkg.version)
await fsPromises.writeFile(file, content, 'utf8')
} catch (err) {
err.message = `${err.message}, file: ${file}`
console.error(err)
}
}
}
main().catch(err => {
console.error(err)
process.exit(1)
})