node-gamedig/bin/genreadme.js

21 lines
649 B
JavaScript
Raw Normal View History

2014-10-29 08:02:03 +01:00
#!/usr/bin/env node
const fs = require('fs'),
GameResolver = require('../lib/GameResolver'),
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.substr(0,start)+"\n\n"+generated+"\n"+readme.substr(end);
2014-10-29 08:02:03 +01:00
fs.writeFileSync(readmeFilename, updated);