UNPKG

nucleus-ui-builder

Version:
47 lines (46 loc) 1.37 kB
function _define_property(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } import fs from "fs"; import path from "path"; import yaml from "js-yaml"; class TemplateLoader { static getInstance() { if (!TemplateLoader.instance) TemplateLoader.instance = new TemplateLoader(); return TemplateLoader.instance; } loadConfig() { try { const fileContents = fs.readFileSync(this.configPath, `utf8`); this._config = this.loader.load(fileContents); } catch (error) { console.error(`Caught error:`, { error }); throw new Error(`File not found: .nucleus.yml`); } } get config() { return this._config; } constructor(){ _define_property(this, "configPath", void 0); _define_property(this, "_config", null); _define_property(this, "loader", yaml); this.configPath = path.resolve(process.cwd(), `.nucleus.yml`); this.loadConfig(); } } _define_property(TemplateLoader, "instance", void 0); export { TemplateLoader as default }; //# sourceMappingURL=template.loader.js.map