ConceptCreator/app/storage/storing/ItemgroupStorage.js

31 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-05-09 09:12:46 +02:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ItemgroupStorage = void 0;
const FileUtils_1 = require("../FileUtils");
const path = require("node:path");
const fs = require("node:fs");
class ItemgroupStorage {
constructor(itemgroupDir) {
this.itemgroupDir = itemgroupDir;
FileUtils_1.FileUtils.prepareDirectoryFroWriting(this.itemgroupDir);
}
storeItemgroups(itemgroups) {
itemgroups.forEach(itemgroup => {
this.storeItemgroup(itemgroup);
});
}
storeItemgroup(itemgroup) {
const file = path.join(...itemgroup.fileName.split("/"));
const completeFileName = path.join(this.itemgroupDir, file);
const itemgroupDirectory = path.join(...itemgroup.fileName.split("/").slice(0, -1));
const completeItemgroupDirectory = path.join(this.itemgroupDir, itemgroupDirectory);
console.log(completeItemgroupDirectory);
FileUtils_1.FileUtils.prepareDirectoryFroWriting(completeItemgroupDirectory);
fs.writeFileSync(completeFileName + ".json", itemgroup.jsonString, "utf-8");
}
storeItems(storedItems) {
storedItems.forEach(item => this.storeItemgroup(item));
}
2024-05-09 09:12:46 +02:00
}
exports.ItemgroupStorage = ItemgroupStorage;
//# sourceMappingURL=ItemgroupStorage.js.map