mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-20 07:05:44 +01:00
Publish what each call writes for chosen corpus examples, and fail the gate where the page is stale
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { readFileSync, writeFileSync } from 'node:fs'
|
||||
import * as library from '@larvit/adf-codec'
|
||||
|
||||
import { renderFeatureTable } from './render.mjs'
|
||||
|
||||
const pagePath = new URL('../docs/feature-table.md', import.meta.url)
|
||||
const readJson = (url) => JSON.parse(readFileSync(url, 'utf8'))
|
||||
|
||||
const examples = readJson(new URL('examples.json', import.meta.url)).map(({ id, name }) => ({ doc: readJson(new URL(`../corpus/round-trip/${id}.json`, import.meta.url)), name }))
|
||||
const page = renderFeatureTable(examples, library)
|
||||
|
||||
if (!process.argv.includes('--check')) writeFileSync(pagePath, page)
|
||||
else if (readFileSync(pagePath, 'utf8') !== page) {
|
||||
console.error('docs/feature-table.md differs from what the examples and the build give: run ./feature-table/write.sh')
|
||||
process.exitCode = 1
|
||||
}
|
||||
Reference in New Issue
Block a user