Skip to content

Commit

Permalink
Fixed missing file issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterbrandsen committed Sep 28, 2023
1 parent 4d7b856 commit 804175b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "screeps-performance-server",
"version": "1.11.3",
"version": "1.12.0",
"dependencies": {
"@octokit/core": "^4.2.0",
"discord.js": "^14.9.0",
Expand Down
9 changes: 5 additions & 4 deletions src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,19 @@ function UpdateBotFolder() {
}

const filesInNewBotFolder = fs.readdirSync(newBotFolder);
const botFiles = filesInNewBotFolder.filter((file) => file.endsWith(".js"));
if (botFiles.length === 0) {
if (filesInNewBotFolder.length === 0) {
console.log("No bot files found in the provided folder");
throw new Error("No bot files found");
}

botFiles.forEach((fileName) => {
filesInNewBotFolder.forEach((fileName) => {
const file = fs.readFileSync(join(newBotFolder, fileName), "utf8");
fs.writeFileSync(join(botFolder, fileName), file);
});

console.log(`Replaced bot folder with an total of ${botFiles.length} files`);
console.log(
`Replaced bot folder with an total of ${filesInNewBotFolder.length} files`
);
}

// eslint-disable-next-line consistent-return
Expand Down

0 comments on commit 804175b

Please sign in to comment.