fix(ci): create posts dir before writing scaffold output (#914)

writeFileSync throws ENOENT when the parent directory does not exist
in a freshly cloned website repo. Call mkdirSync with recursive:true
on the posts dir before writing the file.
This commit is contained in:
Anso
2026-05-04 14:20:46 -04:00
committed by GitHub
parent 67d56f8b54
commit 73b5ca7b34
+2 -1
View File
@@ -8,7 +8,7 @@
// workflow commits it directly to website main. No PR is created or required.
import { execFileSync } from 'node:child_process'
import { readFileSync, writeFileSync, readdirSync, existsSync } from 'node:fs'
import { readFileSync, writeFileSync, readdirSync, existsSync, mkdirSync } from 'node:fs'
import { join, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
@@ -387,6 +387,7 @@ function main() {
console.log(newMeta)
}
} else {
mkdirSync(dirname(postPath), { recursive: true })
writeFileSync(postPath, post, 'utf8')
writeFileSync(indexPath, newIndex, 'utf8')
if (newMeta) writeFileSync(metaPath, newMeta, 'utf8')