ConceptCreator/app/storage/loader/ScriptAccountLoader.js

31 lines
1.4 KiB
JavaScript
Raw Normal View History

"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