Skip to content

Commit

Permalink
fix: Fix using __dirname in the games_list.md generator tool
Browse files Browse the repository at this point in the history
  • Loading branch information
CosminPerRam committed Nov 12, 2023
1 parent 371fad3 commit 4092fe3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
26 changes: 26 additions & 0 deletions tools/generate_games_list.js
Original file line number Diff line number Diff line change
@@ -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 = '<!--- BEGIN GENERATED GAMES -->'
const markerBottom = '<!--- END GENERATED GAMES -->'

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)
21 changes: 0 additions & 21 deletions tools/genreadme.js

This file was deleted.

0 comments on commit 4092fe3

Please sign in to comment.