30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
"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);
|
|
FileUtils_1.FileUtils.prepareDirectoryFroWriting(completeItemgroupDirectory);
|
|
fs.writeFileSync(completeFileName + ".json", itemgroup.jsonString, "utf-8");
|
|
}
|
|
storeItems(storedItems) {
|
|
storedItems.forEach(item => this.storeItemgroup(item));
|
|
}
|
|
}
|
|
exports.ItemgroupStorage = ItemgroupStorage;
|
|
//# sourceMappingURL=ItemgroupStorage.js.map
|