fixed already installed bug

This commit is contained in:
qajus 2025-05-15 19:55:34 +02:00 committed by Rudi Regentonne
parent 148e44a705
commit 2c4114ec0c

View file

@ -4,12 +4,15 @@ const execPromise = util.promisify(exec);
import fs, { read } from "fs"; import fs, { read } from "fs";
import readlineSync from "readline-sync"; import readlineSync from "readline-sync";
import crypto from "crypto"; import crypto from "crypto";
import dotenv from "dotenv"
import path from "path";
const json_path: string = "scripts/install.json"; // Path to the JSON file const json_path: string = "scripts/install.json"; // Path to the JSON file
const raw = fs.readFileSync(json_path, "utf8"); const raw = fs.readFileSync(json_path, "utf8");
const config = JSON.parse(raw); // Parse the JSON file const config = JSON.parse(raw); // Parse the JSON file
if (config.installed) { //check if there is a .env file and abort the installation
if (fs.existsSync(".env") ) {
// Check if the script has already been run // Check if the script has already been run
console.log("Already installed"); console.log("Already installed");
process.exit(0); process.exit(0);
@ -54,11 +57,6 @@ try {
break; // Stop execution if an error occurs break; // Stop execution if an error occurs
} }
} }
config.installed = true; // Set the installed flag to true
fs.writeFile(json_path, JSON.stringify(config), (err) => {
if (err) {
console.error("Error writing to file:", err);
}
});
console.log("Installation complete"); console.log("Installation complete");
})(); })();