diff --git a/tools/generate_games_list.js b/tools/generate_games_list.js new file mode 100644 index 0000000..7e08d6d --- /dev/null +++ b/tools/generate_games_list.js @@ -0,0 +1,26 @@ +#!/usr/bin/env node + +import * as fs from 'node:fs' +import GameResolver from '../lib/GameResolver.js' +import { fileURLToPath } from 'node:url' +import { dirname } from 'node:path' + +const gameResolver = new GameResolver() + +const generated = gameResolver.printReadme() + +const __filename = fileURLToPath(import.meta.url) +const __dirname = dirname(__filename) + +const readmeFilename = __dirname + '/../GAMES_LIST.md' +const readme = fs.readFileSync(readmeFilename, { encoding: 'utf8' }) + +const markerTop = '' +const markerBottom = '' + +let start = readme.indexOf(markerTop) +start += markerTop.length +const end = readme.indexOf(markerBottom) + +const updated = readme.substring(0, start) + '\n\n' + generated + '\n' + readme.substring(end) +fs.writeFileSync(readmeFilename, updated) diff --git a/tools/genreadme.js b/tools/genreadme.js deleted file mode 100644 index b32bcc5..0000000 --- a/tools/genreadme.js +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env node - -import * as fs from 'node:fs' -import GameResolver from '../lib/GameResolver.js' - -const gameResolver = new GameResolver() - -const generated = gameResolver.printReadme() - -const readmeFilename = __dirname + '/../README.md' -const readme = fs.readFileSync(readmeFilename, { encoding: 'utf8' }) - -const marker_top = '' -const marker_bottom = '' - -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)