|
@ -305,38 +305,34 @@ function findModulePath (id, dirs, callback) { |
|
|
var dir = dirs[0]; |
|
|
var dir = dirs[0]; |
|
|
var rest = dirs.slice(1, dirs.length); |
|
|
var rest = dirs.slice(1, dirs.length); |
|
|
|
|
|
|
|
|
var js = path.join(dir, id + ".js"); |
|
|
if (id.charAt(0) == '/') { |
|
|
var addon = path.join(dir, id + ".node"); |
|
|
dir = ''; |
|
|
var indexJs = path.join(dir, id, "index.js"); |
|
|
rest = []; |
|
|
var indexAddon = path.join(dir, id, "index.addon"); |
|
|
} |
|
|
|
|
|
|
|
|
// TODO clean up the following atrocity!
|
|
|
var locations = [ |
|
|
|
|
|
path.join(dir, id + ".js"), |
|
|
path.exists(js, function (found) { |
|
|
path.join(dir, id + ".node"), |
|
|
if (found) { |
|
|
path.join(dir, id, "index.js"), |
|
|
callback(js); |
|
|
path.join(dir, id, "index.addon"), |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
var searchLocations = function() { |
|
|
|
|
|
var location = locations.shift(); |
|
|
|
|
|
if (location === undefined) { |
|
|
|
|
|
findModulePath(id, rest, callback); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
path.exists(addon, function (found) { |
|
|
|
|
|
|
|
|
path.exists(location, function (found) { |
|
|
if (found) { |
|
|
if (found) { |
|
|
callback(addon); |
|
|
callback(location); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
path.exists(indexJs, function (found) { |
|
|
searchLocations(); |
|
|
if (found) { |
|
|
}) |
|
|
callback(indexJs); |
|
|
}; |
|
|
return; |
|
|
searchLocations(); |
|
|
} |
|
|
|
|
|
path.exists(indexAddon, function (found) { |
|
|
|
|
|
if (found) { |
|
|
|
|
|
callback(indexAddon); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
findModulePath(id, rest, callback); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function loadModule (request, parent) { |
|
|
function loadModule (request, parent) { |
|
|