2014-10-29 08:02:03 +01:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
2023-10-10 11:25:57 +02:00
|
|
|
import * as fs from 'node:fs'
|
2023-10-30 22:28:21 +01:00
|
|
|
import GameResolver from '../lib/GameResolver.js'
|
2023-09-14 22:28:31 +02:00
|
|
|
|
2023-09-19 18:52:35 +02:00
|
|
|
const gameResolver = new GameResolver()
|
2014-10-29 08:02:03 +01:00
|
|
|
|
2023-09-19 18:52:35 +02:00
|
|
|
const generated = gameResolver.printReadme()
|
2014-10-29 08:02:03 +01:00
|
|
|
|
2023-09-19 18:52:35 +02:00
|
|
|
const readmeFilename = __dirname + '/../README.md'
|
|
|
|
const readme = fs.readFileSync(readmeFilename, { encoding: 'utf8' })
|
2014-10-29 08:02:03 +01:00
|
|
|
|
2023-09-19 18:52:35 +02:00
|
|
|
const marker_top = '<!--- BEGIN GENERATED GAMES -->'
|
|
|
|
const marker_bottom = '<!--- END GENERATED GAMES -->'
|
2014-10-29 08:02:03 +01:00
|
|
|
|
2023-09-19 18:52:35 +02:00
|
|
|
let start = readme.indexOf(marker_top)
|
|
|
|
start += marker_top.length
|
|
|
|
const end = readme.indexOf(marker_bottom)
|
2014-10-29 08:02:03 +01:00
|
|
|
|
2023-09-19 18:52:35 +02:00
|
|
|
const updated = readme.substring(0, start) + '\n\n' + generated + '\n' + readme.substring(end)
|
|
|
|
fs.writeFileSync(readmeFilename, updated)
|