2021-12-22 13:04:06 +00:00
|
|
|
import { resolve, join } from 'path'
|
|
|
|
import { promises as fsp } from 'fs'
|
2021-12-22 21:27:23 +00:00
|
|
|
import { globby } from 'globby'
|
2021-12-22 13:04:06 +00:00
|
|
|
|
|
|
|
const r = (...path: string[]) => resolve(join(__dirname, '..', ...path))
|
|
|
|
|
|
|
|
async function main () {
|
2021-12-22 21:27:23 +00:00
|
|
|
const templates = await globby(r('dist/templates/*.mjs'))
|
2021-12-22 13:04:06 +00:00
|
|
|
for (const file of templates) {
|
|
|
|
const { template } = await import(file)
|
|
|
|
const updated = template({
|
|
|
|
// messages: {},
|
|
|
|
name: '{{ name }}' // TODO
|
|
|
|
})
|
|
|
|
await fsp.mkdir(file.replace('.mjs', ''))
|
|
|
|
await fsp.writeFile(file.replace('.mjs', '/index.html'), updated)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
main().catch(console.error)
|