From 9d6b118730e07ee70ff706933c95e91389d4bf2f Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 3 Oct 2019 22:23:56 +1000 Subject: [PATCH] Update maploader.js --- maploader.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/maploader.js b/maploader.js index b08f5cc..8932519 100644 --- a/maploader.js +++ b/maploader.js @@ -38,7 +38,13 @@ function copyFiles(source, destination) { } for (i = 0; i < files.length; i++) { - fs.copyFileSync(source + files[i], destination + files[i]); - console.log('Copied ' + files[i] + ' from ' + source + ' to ' + destination); + if (fs.existsSync(destination + files[i])){//deletes existing file in destinations to ensure only files from chosen map set are present in destination + fs.unlinkSync(destination + files[i]); + console.log('Deleted ' + files[i] + ' from ' + destination); + } + if (fs.existsSync(source + files[i])){//checks before copying to prevent errors causing remaining files to fail + fs.copyFileSync(source + files[i], destination + files[i]); + console.log('Copied ' + files[i] + ' from ' + source + ' to ' + destination); + } } }