recime-bot-runtime
Version:
This runtime is intended to run inside a micro-service container with platform specific integration and module interpreter.
49 lines (48 loc) • 1.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var fs = require("fs");
var path = require("path");
var mappings = [];
var MainModule = /** @class */ (function () {
function MainModule(options) {
this.options = options;
var botdir = path.join(options.homedir, "bot");
try {
if (fs.existsSync(botdir)) {
this.botdir = botdir;
}
else {
this.botdir = path.join(options.homedir, options.uid);
}
}
catch (err) {
console.error(err);
}
}
Object.defineProperty(MainModule.prototype, "dir", {
get: function () {
return this.botdir;
},
enumerable: true,
configurable: true
});
MainModule.prototype.path = function () {
return path.join(this.botdir, "main.js");
};
MainModule.prototype.normalizedDepsPath = function (module) {
if (mappings[module]) {
return mappings[module];
}
path.join(this.botdir, "node_modules");
var modulesPath = path.join(this.botdir, "node_modules");
if (module && module.charAt(0) === ".")
mappings[module] = path.resolve(this.botdir, module);
else if (fs.existsSync(path.resolve(modulesPath, module)))
mappings[module] = path.resolve(modulesPath, module);
else
mappings[module] = module;
return mappings[module];
};
return MainModule;
}());
exports.MainModule = MainModule;