node-gamedig/bin/genreadme.js
Tom 01794f6339
Add support for running using deno (#362)
* Add missing CRLF line ending

* Add support for running using deno

Prefix node imports with "node:" and gate a socket API that is not
implemented in [deno](https://deno.land) so that the library can be used
there. This should not break node and doesn't in my brief testing.
2023-10-10 12:25:57 +03:00

21 lines
661 B
JavaScript

#!/usr/bin/env node
import * as fs from 'node:fs'
import GameResolver from '../lib/GameResolver'
const gameResolver = new GameResolver()
const generated = gameResolver.printReadme()
const readmeFilename = __dirname + '/../README.md'
const readme = fs.readFileSync(readmeFilename, { encoding: 'utf8' })
const marker_top = '<!--- BEGIN GENERATED GAMES -->'
const marker_bottom = '<!--- END GENERATED GAMES -->'
let start = readme.indexOf(marker_top)
start += marker_top.length
const end = readme.indexOf(marker_bottom)
const updated = readme.substring(0, start) + '\n\n' + generated + '\n' + readme.substring(end)
fs.writeFileSync(readmeFilename, updated)