From 9563833fdf207b73746727ea5fad9f5a79e2acad Mon Sep 17 00:00:00 2001 From: chris062689 Date: Sun, 4 Jun 2017 17:19:50 -0400 Subject: [PATCH] Using path.extname instead of slice for detecting file extensions. --- scripts/games/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/games/app.js b/scripts/games/app.js index 9d77ff7..409ccf9 100644 --- a/scripts/games/app.js +++ b/scripts/games/app.js @@ -105,9 +105,9 @@ try { // Copy all savefiles into the output folder and store their contents. fs.readdirSync(inputDirectorySavefilesGame).forEach(file => { - if (file.slice(-5) == '.zip') { + if (path.extname(file) == '.zip') { fsextra.copySync(`${inputDirectorySavefilesGame}/${file}`, `${outputDirectorySavefilesGame}/${file.replace('.zip', '.csav')}`); - } else if (file.slice(-4) == '.dat') { + } else if (path.extname(file) == '.dat') { // Store the contents of the file in memory for adding it into the markdown later. savefileMetadataContents.push({ filename: file.replace('.dat', '.csav'), contents: fs.readFileSync(`${inputDirectorySavefilesGame}/${file}`, 'utf8') }); } @@ -126,7 +126,7 @@ try { // Copy all screenshots into the output folder. fs.readdirSync(inputDirectoryScreenshotsGame).forEach(file => { - if (file.slice(-4) == '.png') { + if (path.extname(file) == '.png') { fsextra.copySync(`${inputDirectoryScreenshotsGame}/${file}`, `${outputDirectoryScreenshotsGame}/${file}`); } });