Fix plugin loader to work with windows paths (e.g. 'D:\foo\...')

pull/822/head
Marcel Klehr 2012-06-28 15:58:28 +02:00
parent 711dee8f6b
commit b0d369883b
1 changed files with 15 additions and 3 deletions

View File

@ -54,10 +54,22 @@ exports.formatHooks = function (hook_set_name) {
};
exports.loadFn = function (path, hookName) {
var x = path.split(":");
var fn = require(x[0]);
var functionName = x[1] ? x[1] : hookName;
var functionName
, parts = path.split(":");
// on windows
if(process.platform == 'win32') {
if(parts.length == 3)
functionName = parts.pop();
path = parts.join(":");
}else{
path = parts[0];
functionName = parts[1];
}
var fn = require(path);
functionName = functionName ? functionName : hookName;
_.each(functionName.split("."), function (name) {
fn = fn[name];
});