node-gamedig/tools/genreadme.js

22 lines
664 B
JavaScript
Raw Normal View History

2014-10-29 08:02:03 +01:00
#!/usr/bin/env node
import * as fs from 'node:fs'
import GameResolver from '../lib/GameResolver.js'
const gameResolver = new GameResolver()
2014-10-29 08:02:03 +01:00
const generated = gameResolver.printReadme()
2014-10-29 08:02:03 +01:00
const readmeFilename = __dirname + '/../README.md'
const readme = fs.readFileSync(readmeFilename, { encoding: 'utf8' })
2014-10-29 08:02:03 +01:00
const marker_top = '<!--- BEGIN GENERATED GAMES -->'
const marker_bottom = '<!--- END GENERATED GAMES -->'
2014-10-29 08:02:03 +01: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
const updated = readme.substring(0, start) + '\n\n' + generated + '\n' + readme.substring(end)
fs.writeFileSync(readmeFilename, updated)