Skip to content

Commit

Permalink
Changed API from _handleExports to _registerModule
Browse files Browse the repository at this point in the history
  • Loading branch information
xcambar committed Apr 14, 2012
1 parent 0fe2f0b commit e39fd5a
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/shepherd.js
Expand Up @@ -223,18 +223,21 @@
* @param {Object} moduleConf The result of the parsing of the module configuration
* @param {Function} callback The callback function to be called after the successful export
*/
function _handleExports (module, moduleConf) {
if (moduleConf._internals.src) {
if (modules[moduleConf._internals.src]) {
return 'Duplicating module ' + moduleConf._internals.src;
function _registerModule (module, src, name) {

if (src) {
var existingMod = modules[src];
if (existingMod && !when.isPromise(existingMod)) {
return 'Duplicating module ' + src;
}
modules[moduleConf._internals.src] = module;
modules[src] = module;
}
if (moduleConf.name) {
if (modules[moduleConf.name]) {
return 'Duplicating module ' + moduleConf.name;
if (name) {
var existingMod = modules[name];
if (existingMod && !when.isPromise(existingMod)) {
return 'Duplicating module ' + name;
}
modules[moduleConf.name] = module;
modules[name] = module;
}
}

Expand Down Expand Up @@ -274,7 +277,7 @@
me.s6d[extDepIndex] = function (exports) {
if (exports) {
delete me.s6d[extDepIndex];
var _err = _handleExports(module, moduleConf);
var _err = _registerModule(module, moduleConf._internals.src, moduleConf.name);
if (_err) {
return _err;
}
Expand All @@ -290,7 +293,7 @@
fn = Function.apply({}, argsName.concat([contents + ';\nreturn ' + returns]));
}
module = fn.apply({}, moduleArgs);
var _err = _handleExports(module, moduleConf)
var _err = _registerModule(module, moduleConf._internals.src, moduleConf.name)
if (_err) {
return _err;
}
Expand Down Expand Up @@ -335,7 +338,7 @@
module[i] = context.module.exports[i];
}
}
var _err = _handleExports(module, moduleConf);
var _err = _registerModule(module, moduleConf._internals.src, moduleConf.name);
if (_err) {
return _err;
}
Expand Down

0 comments on commit e39fd5a

Please sign in to comment.