Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Commit

Permalink
Add script to revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
EsotericEnderman committed Jun 29, 2024
1 parent f4ed74c commit a8d3494
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "A program that optimises the boot of Minecraft Dungeons by removing the unnecessary loading videos.",
"main": "distrib/main.js",
"scripts": {
"test": "node ."
"remove-loading-videos": "node .",
"revert-changes": "node distrib/scripts/revert-changes.js"
},
"keywords": [
"minecraft",
Expand Down
31 changes: 31 additions & 0 deletions src/scripts/revert-changes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { readFileSync, rmSync, writeFileSync } from "fs";
import { archivedVideoEnding, blankSplashContent, moviesFolder, splashesToRemove } from "../constants";

export function revertChanges() {
for (const loadingVideo of splashesToRemove) {
const fullFilePath = moviesFolder + "/" + loadingVideo;

// Save content to new file, in case the user wants to re-add the loading videos
const split = fullFilePath.split(".");
split[1] = archivedVideoEnding;

let archivedVideoFilePath = split.join("")
archivedVideoFilePath += ".mp4";

let content: Buffer;

try {
content = readFileSync(archivedVideoFilePath);
} catch (error) {
console.log("Could not read file " + archivedVideoFilePath + ".");
continue;
}

console.log("Reverting deletion of video " + fullFilePath + ".");

writeFileSync(fullFilePath, content);
rmSync(archivedVideoFilePath);
}
}

revertChanges();

0 comments on commit a8d3494

Please sign in to comment.