Object.defineProperty(exports, "__esModule", { value: true }); exports.FileHandler = void 0; var fs_1 = require("fs"); var path = require("path"); var Logger_1 = require("./Logger"); var fs = require("fs-extra"); var ensureDir = fs.ensureDir, pathExists = fs.pathExists, readJson = fs.readJson; var FileHandler = /** @class */ (function () { function FileHandler() { } FileHandler.prototype.load = function (callback) { var _this = this; (0, Logger_1.Log)('info', 'Preparing files'); ensureDir(path.join(Undecked.dataPath), function (err) { if (err) throw err; _this.loadConfig(function () { callback(); }); }); }; FileHandler.prototype.loadConfig = function (callback) { var _this = this; this.configPath = path.join(Undecked.dataPath, 'config.json'); pathExists(this.configPath, function (err, exists) { if (err) throw err; if (exists) { readJson(_this.configPath, function (err, json) { if (err) throw err; Config = json; callback(); }); } else { Config = defaultConfig; _this.saveConfig(callback); } }); }; FileHandler.prototype.saveConfig = function (callback) { (0, fs_1.writeFile)(this.configPath, JSON.stringify(Config, null, 4), function (err) { if (err) (0, Logger_1.Log)('error', 'Error whilst saving config', err.message); if (callback) callback(); }); }; return FileHandler; }()); exports.FileHandler = FileHandler; var defaultConfig = { ports: { http: 9999 }, name: null }; //# sourceMappingURL=FileHandler.js.map