Permalink
Browse files

load modules in order they are in app package.json katana.modules

  • Loading branch information...
1 parent 3e1da4c commit 9a3e038d3576d4d045ac0ec73a14016d1ffce792 @Shogun147 committed Oct 18, 2012
Showing with 9 additions and 28 deletions.
  1. +2 −2 lib/katana.js
  2. +6 −23 lib/module.js
  3. +1 −3 template/application/config/development/application.js
View
@@ -31,7 +31,7 @@ Class('Katana', {
isa: EventEmitter,
have: {
- about: {},
+ info: {},
server: null,
controllers: []
},
@@ -40,7 +40,7 @@ Class('Katana', {
initialize: function() {
var App = this;
- App.about = require(mod_root + 'package.json');
+ App.info = require(root +'package.json');
process.nextTick(function() {
App.boot();
View
@@ -9,8 +9,6 @@ var Router = require('./router');
var load = App.Utils.load;
var merge = App.Utils.merge;
-var modules = {};
-
Class('Katana.Core.Module', {
have: {
name: 'Katana.Module',
@@ -72,6 +70,8 @@ Class('Katana.Core.Module', {
}
});
+var modules = {};
+
module.exports = Module = function(module) {
if (module === '*') {
return modules;
@@ -82,27 +82,10 @@ module.exports = Module = function(module) {
return Katana.Core.Module;
}
-var required_modules = Array.isArray(Config().modules) ? Config().modules.slice() : [];
-var all_modules = [];
-
-if (Fs.existsSync(root + 'modules')) {
- Fs.readdirSync(root + 'modules').forEach(function(module) {
- all_modules.push(Path.basename(module, Path.extname(module)));
- });
-
- required_modules.slice().forEach(function(module) {
- all_modules.forEach(function(m) {
- if (module == m) {
- modules[module] = module;
-
- required_modules.splice(required_modules.indexOf(module), 1);
- }
- });
- });
-}
-
-if (required_modules.length) {
- throw new Error('Could not found modules: '+ required_modules.join(', '));
+for (var module in App.info.katana.modules) {
+ if (App.info.katana.modules[module].enabled) {
+ modules[module] = module;
+ }
}
App.on('boot.config', function(callback) {
@@ -56,7 +56,5 @@ module.exports = {
max_age: 0,
hiddens: false,
get_only: true
- },
-
- modules: []
+ }
}

0 comments on commit 9a3e038

Please sign in to comment.