mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
Removed sandbox from apps service
no-issue The instansiation of a Module object was only used so that we could override the require method inside external apps, now we have no support for them, we are free to require the internal apps directly. This has no functionality change.
This commit is contained in:
parent
4696d70de0
commit
d31395412b
@ -1,31 +1,22 @@
|
||||
const path = require('path');
|
||||
const _ = require('lodash');
|
||||
const Promise = require('bluebird');
|
||||
const config = require('../../config');
|
||||
const common = require('../../lib/common');
|
||||
const config = require('../../config');
|
||||
const Proxy = require('./proxy');
|
||||
const Sandbox = require('./sandbox');
|
||||
|
||||
// Get the full path to an app by name
|
||||
function getAppAbsolutePath(name) {
|
||||
return path.join(config.get('paths').internalAppPath, name);
|
||||
}
|
||||
|
||||
// Get a relative path to the given apps root, defaults
|
||||
// to be relative to __dirname
|
||||
function getAppRelativePath(name, relativeTo = __dirname) {
|
||||
const relativePath = path.relative(relativeTo, getAppAbsolutePath(name));
|
||||
|
||||
if (relativePath.charAt(0) !== '.') {
|
||||
return './' + relativePath;
|
||||
}
|
||||
|
||||
return relativePath;
|
||||
function loadApp(name) {
|
||||
return require(getAppAbsolutePath(name));
|
||||
}
|
||||
|
||||
function getAppByName(name) {
|
||||
// Grab the app class to instantiate
|
||||
const AppClass = Sandbox.loadApp(getAppRelativePath(name));
|
||||
const AppClass = loadApp(name);
|
||||
const proxy = Proxy.getInstance(name);
|
||||
|
||||
// Check for an actual class, otherwise just use whatever was returned
|
||||
|
@ -1,13 +0,0 @@
|
||||
const Module = require('module');
|
||||
|
||||
module.exports.loadApp = function loadAppSandboxed(appPath) {
|
||||
// Resolve the modules path
|
||||
const resolvedModulePath = Module._resolveFilename(appPath, module.parent);
|
||||
|
||||
// Instantiate a Node Module class
|
||||
const currentModule = new Module(resolvedModulePath, module.parent);
|
||||
|
||||
currentModule.load(currentModule.id);
|
||||
|
||||
return currentModule.exports;
|
||||
};
|
Loading…
Reference in New Issue
Block a user