| 1 | import { execSync } from 'node:child_process' |
| 2 | import { copyFileSync, mkdirSync, readdirSync, rmSync } from 'node:fs' |
| 3 | import { dirname, join } from 'node:path' |
| 4 | import { fileURLToPath } from 'node:url' |
| 5 | |
| 6 | try { |
| 7 | mkdirSync(join(dirname(fileURLToPath(import.meta.url)), 'tmp'), { |
| 8 | recursive: true, |
| 9 | }) |
| 10 | const markdownFiles = readdirSync( |
| 11 | join(dirname(fileURLToPath(import.meta.url)), 'docs') |
| 12 | ).filter(file => file.endsWith('.md')) |
| 13 | for (const markdownFile of markdownFiles) { |
| 14 | copyFileSync( |
| 15 | join(dirname(fileURLToPath(import.meta.url)), 'docs', markdownFile), |
| 16 | join(dirname(fileURLToPath(import.meta.url)), 'tmp', markdownFile) |
| 17 | ) |
| 18 | } |
| 19 | execSync('npx typedoc', { stdio: 'inherit' }) |
| 20 | for (const markdownFile of markdownFiles) { |
| 21 | copyFileSync( |
| 22 | join(dirname(fileURLToPath(import.meta.url)), 'tmp', markdownFile), |
| 23 | join(dirname(fileURLToPath(import.meta.url)), 'docs', markdownFile) |
| 24 | ) |
| 25 | } |
| 26 | rmSync(join(dirname(fileURLToPath(import.meta.url)), 'tmp'), { |
| 27 | recursive: true, |
| 28 | force: true, |
| 29 | }) |
| 30 | } catch (e) { |
| 31 | console.error(e) |
| 32 | } |