node-gamedig/bin/genreadme.js

20 lines
610 B
JavaScript
Raw Normal View History

2014-10-29 08:02:03 +01:00
#!/usr/bin/env node
const fs = require('fs'),
TypeResolver = require('../lib/typeresolver');
2014-10-29 08:02:03 +01:00
const generated = TypeResolver.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);