node-gamedig/bin/genreadme.js

22 lines
655 B
JavaScript
Raw Normal View History

2014-10-29 08:02:03 +01:00
#!/usr/bin/env node
import * as fs from 'fs';
import GameResolver from "../lib/GameResolver";
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);
2014-10-29 08:02:03 +01:00
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);
2014-10-29 08:02:03 +01:00
fs.writeFileSync(readmeFilename, updated);