Create mods directory for each game from wiki repo

This commit is contained in:
Vamsi Krishna 2022-08-11 00:51:51 +05:30 committed by GitHub
parent 6607aac2f2
commit 644a99b2c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,7 @@ const fsPathHugoBoxart = `${fsPathHugo}/static/images/game/boxart`
const fsPathHugoIcon = `${fsPathHugo}/static/images/game/icons`
const fsPathHugoScreenshots = `${fsPathHugo}/static/images/screenshots0`
const fsPathHugoSavefiles = `${fsPathHugo}/static/savefiles/`
const fsPathHugoMods = `${fsPathHugo}/mods/`
process.on('unhandledRejection', err => {
logger.error('Unhandled rejection on process.');
@ -37,7 +38,7 @@ function gitPull(directory, repository) {
async function run() {
// Make sure the output directories in Hugo exist.
[fsPathHugoContent, fsPathHugoBoxart, fsPathHugoIcon, fsPathHugoSavefiles, fsPathHugoScreenshots].forEach(function (path) {
[fsPathHugoContent, fsPathHugoBoxart, fsPathHugoIcon, fsPathHugoSavefiles, fsPathHugoScreenshots, fsPathHugoMods].forEach(function (path) {
if (fs.existsSync(path) == false) {
logger.info(`Creating Hugo output directory: ${path}`);
fs.ensureDirSync(path);
@ -96,6 +97,24 @@ async function run() {
}
// END SAVEFILE BLOCK
// MODS BLOCK
let fsPathModsInputGame = `${fsPathCode}/{x.id}/mods/`;
let fsPathModsOutputGame = `${fsPathHugoMods}/{x.id}/`;
if (fs.existsSync(fsPathModsInputGame)) {
// Create the mods directory for each game.
if (fs.existsSync(fsPathModsOutputGame) == false) {
fs.mkdirSync(fsPathModsOutputGame);
}
// Copy all the mods into the output folder
fs.readdirSync(fsPathModsInputGame).forEach(file => {
if (path.extname(file) == '.zip' ) {
fs.copySync(`${fsPathModsInputGame}/${file}`, `${fsPathModsOutputGame}/${file}`);
}
});
}
// END MODS BLOCK
// Copy the screenshots for the game.
let fsPathScreenshotInputGame = `${fsPathCode}/${x.id}/screenshots/`;
let fsPathScreenshotOutputGame = `${fsPathHugoScreenshots}/${x.id}/`;