mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05: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
2 changed files with 4 additions and 26 deletions
|
@ -1,31 +1,22 @@
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
const config = require('../../config');
|
|
||||||
const common = require('../../lib/common');
|
const common = require('../../lib/common');
|
||||||
|
const config = require('../../config');
|
||||||
const Proxy = require('./proxy');
|
const Proxy = require('./proxy');
|
||||||
const Sandbox = require('./sandbox');
|
|
||||||
|
|
||||||
// Get the full path to an app by name
|
// Get the full path to an app by name
|
||||||
function getAppAbsolutePath(name) {
|
function getAppAbsolutePath(name) {
|
||||||
return path.join(config.get('paths').internalAppPath, name);
|
return path.join(config.get('paths').internalAppPath, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a relative path to the given apps root, defaults
|
function loadApp(name) {
|
||||||
// to be relative to __dirname
|
return require(getAppAbsolutePath(name));
|
||||||
function getAppRelativePath(name, relativeTo = __dirname) {
|
|
||||||
const relativePath = path.relative(relativeTo, getAppAbsolutePath(name));
|
|
||||||
|
|
||||||
if (relativePath.charAt(0) !== '.') {
|
|
||||||
return './' + relativePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
return relativePath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAppByName(name) {
|
function getAppByName(name) {
|
||||||
// Grab the app class to instantiate
|
// Grab the app class to instantiate
|
||||||
const AppClass = Sandbox.loadApp(getAppRelativePath(name));
|
const AppClass = loadApp(name);
|
||||||
const proxy = Proxy.getInstance(name);
|
const proxy = Proxy.getInstance(name);
|
||||||
|
|
||||||
// Check for an actual class, otherwise just use whatever was returned
|
// 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…
Add table
Reference in a new issue