ConceptCreator/app/storage/loader/ScriptAccountLoader.js
Sebastian Böckelmann b31f72475a
Some checks failed
E2E Testing / test (push) Failing after 1m31s
Introduce Project Service as interface to persistance of gamemodel
2024-03-20 09:26:52 +01:00

31 lines
1.4 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScriptAccountLoader = void 0;
const StoreComponent_1 = require("../StoreComponent");
const FileUtils_1 = require("../FileUtils");
const ModelComponentType_1 = require("../../../src/app/project/game-model/ModelComponentType");
const fs = require("fs");
class ScriptAccountLoader {
constructor(scriptAccountDir) {
this.scriptAccountDir = scriptAccountDir;
}
loadScriptAccounts() {
const scriptAccountFiles = FileUtils_1.FileUtils.listFilesInDirectory(this.scriptAccountDir);
const loadedScriptAccounts = [];
scriptAccountFiles.forEach(scriptAccountFile => {
const loadedScriptAccount = this.loadScriptAccount(scriptAccountFile);
if (loadedScriptAccount != undefined) {
loadedScriptAccounts.push(loadedScriptAccount);
}
});
return loadedScriptAccounts;
}
loadScriptAccount(scriptAccountFile) {
if (scriptAccountFile.endsWith(".json")) {
const scriptAccountData = fs.readFileSync(scriptAccountFile, 'utf-8');
return new StoreComponent_1.StoreComponent(scriptAccountData, scriptAccountFile, ModelComponentType_1.ModelComponentType.SCRIPTACCOUNT);
}
}
}
exports.ScriptAccountLoader = ScriptAccountLoader;
//# sourceMappingURL=ScriptAccountLoader.js.map