Autoload module from current directory when under development
This commit is contained in:
parent
3787ebda6a
commit
17e9cee6dc
|
@ -1,7 +1,8 @@
|
|||
"use strict";
|
||||
|
||||
var Logger = require("./logger"),
|
||||
_ = require("./utils/helpers");
|
||||
_ = require("./utils/helpers"),
|
||||
path = require("path");
|
||||
|
||||
// Explicitly these modules here, so Browserify can grab them later
|
||||
require("./test/loopback");
|
||||
|
@ -30,7 +31,11 @@ var Registry = module.exports = {
|
|||
var pkg;
|
||||
|
||||
try {
|
||||
pkg = require(module);
|
||||
if (this.isModuleInDevelopment(module)) {
|
||||
pkg = require(path.resolve(".") + "/index");
|
||||
} else {
|
||||
pkg = require(module);
|
||||
}
|
||||
} catch (e) {
|
||||
if (e.code === "MODULE_NOT_FOUND") {
|
||||
missingModuleError(module);
|
||||
|
@ -99,6 +104,10 @@ var Registry = module.exports = {
|
|||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
isModuleInDevelopment: function(module) {
|
||||
return (path.basename(path.resolve(".")) === module);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue