decova-gotcha
Version:
It's my personal trial for automating daunting tasks
48 lines • 1.92 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WalkthroughsSheet = void 0;
const decova_json_1 = require("decova-json");
const PathMan_1 = require("../local-tools-impl/Techies/PathMan");
const TerminalAgent_1 = require("./TerminalAgent");
const tsyringe_1 = require("tsyringe");
class WalkthroughsSheet {
constructor() {
this.srv_PathMan = tsyringe_1.container.resolve(PathMan_1.PathMan);
this.CreatedOn = new Date();
}
CacheWalkthroughs() {
const output = [];
for (let prop in this.Walkthroughs) {
output.xAdd(Object.assign(Object.assign({}, this.Walkthroughs[prop]), { Title: prop }));
}
this.WalkthroughList = output;
}
FileExists() {
return this.srv_PathMan.GotchaLocalRepo_WalkthroughsSheet.Exists();
}
static get Singleton() {
if (this._singleton)
return this._singleton;
const pathMan = tsyringe_1.container.resolve(PathMan_1.PathMan);
if (pathMan.GotchaLocalRepo_WalkthroughsSheet.Exists() == false)
return null;
let singletonData;
try {
singletonData = decova_json_1.Json.Load(pathMan.GotchaLocalRepo_WalkthroughsSheet.FullName);
}
catch (err) {
TerminalAgent_1.TerminalAgent.ShowError(`Couldn't load Walkthroughs sheet \r\n ${JSON.stringify(err)}`);
throw {
error: `Couldn't load Walkthroughs sheet`,
innerException: JSON.stringify(err)
};
}
this._singleton = new WalkthroughsSheet();
Object.assign(this._singleton, singletonData);
this._singleton.CacheWalkthroughs();
return this._singleton;
}
}
exports.WalkthroughsSheet = WalkthroughsSheet;
WalkthroughsSheet._singleton = null;
//# sourceMappingURL=WalkthroughsSheet.js.map