2019-04-15 13:12:18 +03:00
|
|
|
const Module = require('module');
|
2014-02-01 02:53:27 +04:00
|
|
|
|
2019-04-15 13:13:50 +03:00
|
|
|
module.exports.loadApp = function loadAppSandboxed(appPath) {
|
2014-02-01 02:53:27 +04:00
|
|
|
// Resolve the modules path
|
2019-04-15 13:13:50 +03:00
|
|
|
const resolvedModulePath = Module._resolveFilename(appPath, module.parent);
|
2014-02-01 02:53:27 +04:00
|
|
|
|
|
|
|
// Instantiate a Node Module class
|
2019-04-15 13:13:50 +03:00
|
|
|
const currentModule = new Module(resolvedModulePath, module.parent);
|
2014-02-01 02:53:27 +04:00
|
|
|
|
|
|
|
currentModule.load(currentModule.id);
|
|
|
|
|
|
|
|
return currentModule.exports;
|
|
|
|
};
|