ConceptCreator/app/DeleteModel.js

50 lines
2.0 KiB
JavaScript
Raw Normal View History

2024-03-19 17:03:07 +01:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteTransaction = void 0;
const path = require("node:path");
const fs = require("fs");
class DeleteTransaction {
static deleteScriptAccount(projectDir, componentName) {
const filename = path.join(projectDir, "script-accounts", componentName + ".json");
fs.unlinkSync(filename);
console.log("Delete ", filename);
}
2024-03-19 17:55:11 +01:00
static deleteGamesystem(projectDir, componentName) {
const gamesystemDir = path.join(projectDir, "gamesystems");
const gamesystemFile = this.findGamesystemPath(gamesystemDir, componentName);
try {
if (gamesystemFile != undefined) {
console.log("Delete Gamesystem under File: ", gamesystemFile);
if (fs.lstatSync(gamesystemFile).isDirectory()) {
fs.rmSync(gamesystemFile, { recursive: true, force: true });
}
else {
fs.unlinkSync(gamesystemFile);
}
}
}
catch (e) {
console.log(e);
}
}
static findGamesystemPath(gamesystemRootDir, searchedFilename) {
const directoriesToProcess = [];
directoriesToProcess.push(gamesystemRootDir);
while (directoriesToProcess.length > 0) {
const currentDirectory = directoriesToProcess.shift();
const filesInDirectory = fs.readdirSync(currentDirectory);
for (let i = 0; i < filesInDirectory.length; i++) {
const currentFile = path.join(currentDirectory, filesInDirectory[i]);
if (fs.lstatSync(currentFile).isDirectory()) {
directoriesToProcess.push(currentFile);
}
if (path.parse(path.basename(currentFile)).name === searchedFilename) {
return currentFile;
}
}
}
return undefined;
}
2024-03-19 17:03:07 +01:00
}
exports.DeleteTransaction = DeleteTransaction;
//# sourceMappingURL=DeleteModel.js.map