UNPKG

@remote.it/core

Version:

Core remote.it JavasScript/TypeScript library

103 lines 3.5 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var JSONFile_1 = require("./JSONFile"); var Environment_1 = require("./Environment"); var Logger_1 = require("./Logger"); var ConfigFile = /** @class */ (function (_super) { __extends(ConfigFile, _super); function ConfigFile(location) { if (location === void 0) { location = Environment_1.Environment.configPath; } var _this = _super.call(this, location) || this; // Make sure file exists if (!_this.exists || !_this.content) { Logger_1.Logger.info('config file does not exist, creating', { location: location }); _this.write({ registrationKey: undefined, initiators: [], services: [], target: undefined, user: undefined, }); } return _this; } Object.defineProperty(ConfigFile.prototype, "registrationKey", { get: function () { return this.read().registrationKey; }, set: function (registrationKey) { var json = this.read(); json.registrationKey = registrationKey; this.write(json); }, enumerable: true, configurable: true }); Object.defineProperty(ConfigFile.prototype, "target", { get: function () { return this.read().target || undefined; }, set: function (target) { var json = this.read(); json.target = target; this.write(json); }, enumerable: true, configurable: true }); Object.defineProperty(ConfigFile.prototype, "services", { get: function () { return this.read().services || []; }, set: function (services) { var json = this.read(); json.services = services; this.write(json); }, enumerable: true, configurable: true }); Object.defineProperty(ConfigFile.prototype, "initiators", { get: function () { return this.read().initiators || []; }, set: function (initiators) { var json = this.read(); json.initiators = initiators; this.write(json); }, enumerable: true, configurable: true }); Object.defineProperty(ConfigFile.prototype, "user", { get: function () { var content = this.read(); if (!content || !content.user) return; return content.user; }, set: function (user) { var json = this.read(); json.user = user; this.write(json); }, enumerable: true, configurable: true }); return ConfigFile; }(JSONFile_1.JSONFile)); exports.ConfigFile = ConfigFile; //# sourceMappingURL=ConfigFile.js.map