Continue building other games if exception is encountered. Added checks for if wiki article exists.

This commit is contained in:
chris062689 2017-06-04 21:27:57 -04:00
parent 4a711aa686
commit 30e0888233

View File

@ -76,6 +76,7 @@ if (fs.existsSync(outputDirectoryScreenshots) == false) {
try {
// Loop through each game folder.
getDirectories(inputDirectoryGame).forEach(function(game) {
try {
if (game == '.git') { return; }
logger.info(`Creating Hugo files for ${game}`);
@ -139,7 +140,14 @@ try {
let modified = new Date(util.inspect(stats.mtime));
let datContents = fs.readFileSync(`${inputDirectoryGame}/${game}/game.dat`, 'utf8');
let wikiContents = fs.readFileSync(`${inputDirectoryWiki}/${game}.md`, 'utf8');
var wikiContents = "";
let wikiPathGame = `${inputDirectoryWiki}/${game}.md`;
if (fs.existsSync(wikiPathGame)) {
wikiContents = fs.readFileSync(wikiPathGame, 'utf8');
} else {
wikiContents = "No wiki exists yet for this game.";
}
// Fix Blackfriday markdown rendering differences.
wikiContents = blackfriday.fixLists(wikiContents);
@ -153,6 +161,9 @@ try {
let output = `+++\r\ndate = "${modified.toISOString()}"\r\n${datContents}\r\n+++\r\n\r\n${wikiContents}\r\n`;
fs.writeFileSync(`${outputDirectoryMd}/${game}.md`, output);
} catch (ex) {
logger.error(`${game} failed to generate: ${ex}`);
}
});
} catch (ex) {
logger.error(ex);