fixing path resolution for plugins in production mode

v1.18.x
Julian Lam 11 years ago
parent 5e2460e17e
commit 5540313b7f

@ -3,6 +3,7 @@ var fs = require('fs'),
async = require('async'), async = require('async'),
winston = require('winston'), winston = require('winston'),
nconf = require('nconf'), nconf = require('nconf'),
_ = require('underscore'),
utils = require('./../public/src/utils'), utils = require('./../public/src/utils'),
translator = require('./../public/src/translator'), translator = require('./../public/src/translator'),
@ -250,12 +251,17 @@ var fs = require('fs'),
jsPath = path.normalize(jsPath); jsPath = path.normalize(jsPath);
if (jsPath.substring(0, 7) === 'plugins') { if (jsPath.substring(0, 7) === 'plugins') {
var paths = jsPath.split(path.sep), var matches = _.map(plugins.staticDirs, function(realPath, mappedPath) {
mappedPath = paths[1]; if (jsPath.match(mappedPath)) {
return mappedPath;
} else {
return null;
}
}).filter(function(a) { return a; });
if (plugins.staticDirs[mappedPath]) { if (matches.length) {
jsPath = jsPath.replace(path.join('plugins', mappedPath), ''); var relPath = jsPath.slice(new String('plugins/' + matches[0]).length);
return path.join(plugins.staticDirs[mappedPath], jsPath); return plugins.staticDirs[matches[0]] + relPath;
} else { } else {
winston.warn('[meta.scripts.get] Could not resolve mapped path: ' + mappedPath + '. Are you sure it is defined by a plugin?'); winston.warn('[meta.scripts.get] Could not resolve mapped path: ' + mappedPath + '. Are you sure it is defined by a plugin?');
return null; return null;

Loading…
Cancel
Save