Continue building other games if exception is encountered. Added checks for if wiki article exists.
This commit is contained in:
parent
4a711aa686
commit
30e0888233
|
@ -76,6 +76,7 @@ if (fs.existsSync(outputDirectoryScreenshots) == false) {
|
||||||
try {
|
try {
|
||||||
// Loop through each game folder.
|
// Loop through each game folder.
|
||||||
getDirectories(inputDirectoryGame).forEach(function(game) {
|
getDirectories(inputDirectoryGame).forEach(function(game) {
|
||||||
|
try {
|
||||||
if (game == '.git') { return; }
|
if (game == '.git') { return; }
|
||||||
|
|
||||||
logger.info(`Creating Hugo files for ${game}`);
|
logger.info(`Creating Hugo files for ${game}`);
|
||||||
|
@ -139,7 +140,14 @@ try {
|
||||||
let modified = new Date(util.inspect(stats.mtime));
|
let modified = new Date(util.inspect(stats.mtime));
|
||||||
|
|
||||||
let datContents = fs.readFileSync(`${inputDirectoryGame}/${game}/game.dat`, 'utf8');
|
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.
|
// Fix Blackfriday markdown rendering differences.
|
||||||
wikiContents = blackfriday.fixLists(wikiContents);
|
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`;
|
let output = `+++\r\ndate = "${modified.toISOString()}"\r\n${datContents}\r\n+++\r\n\r\n${wikiContents}\r\n`;
|
||||||
fs.writeFileSync(`${outputDirectoryMd}/${game}.md`, output);
|
fs.writeFileSync(`${outputDirectoryMd}/${game}.md`, output);
|
||||||
|
} catch (ex) {
|
||||||
|
logger.error(`${game} failed to generate: ${ex}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
logger.error(ex);
|
logger.error(ex);
|
||||||
|
|
Reference in New Issue