Permalink
Browse files

made bin/nervous a simple wrapper

  • Loading branch information...
1 parent 9794d6a commit e36cc11fab67a455984e7415309193c1b3d25591 Geoff Flarity committed Feb 7, 2012
Showing with 40 additions and 38 deletions.
  1. +2 −38 bin/nervous
  2. +38 −0 lib/nervous.js
View
@@ -1,40 +1,4 @@
#!/usr/bin/env node
-
-//deps
-var fs = require('fs');
-var path = require('path');
-
-//code
-var full_path_of_config = require.resolve( '../conf/nervous.json' );
-var config = JSON.parse(fs.readFileSync( full_path_of_config ) );
-
-var system_type = config.system_type;
-var axon_factory = require('../lib/axon_factory')( system_type, config );
-
-var plugins_home = '../plugins';
-var full_path_of_test_js = require.resolve( plugins_home + '/test.js' );
-var full_plugins_path = path.dirname( full_path_of_test_js ) + '/node_modules';
-
-var load_plugins = function () {
- fs.readdir( full_plugins_path, function( err, entries ) {
- var dirs = [];
- entries = entries || [];
- entries.forEach( function( entry ) {
-
- var plugin = full_plugins_path + '/' + entry;
- fs.stat( plugin, function( err, stats ) {
- if ( stats.isDirectory() ) {
- require( plugin )( axon_factory( entry ) );
- }
- } );
- } );
-
-
- }
-
- );
-};
-
-
-load_plugins();
+//thin wrapper
+require('../lib/nervous.js')();
View
@@ -0,0 +1,38 @@
+//deps
+var fs = require('fs');
+var path = require('path');
+
+//code
+var load_plugins = function () {
+ var full_path_of_config = require.resolve( '../conf/nervous.json' );
+ var config = JSON.parse(fs.readFileSync( full_path_of_config ) );
+
+ var system_type = config.system_type;
+ var axon_factory = require('../lib/axon_factory')( system_type, config );
+
+ var plugins_home = '../plugins';
+ var full_path_of_test_js = require.resolve( plugins_home + '/test.js' );
+ var full_plugins_path = path.dirname( full_path_of_test_js ) + '/node_modules';
+
+ fs.readdir( full_plugins_path, function( err, entries ) {
+ var dirs = [];
+ entries = entries || [];
+ entries.forEach( function( entry ) {
+
+ var plugin = full_plugins_path + '/' + entry;
+ fs.stat( plugin, function( err, stats ) {
+ if ( stats.isDirectory() ) {
+ require( plugin )( axon_factory( entry ) );
+ }
+ } );
+ } );
+
+
+ }
+
+ );
+};
+
+module.exports = function() {
+ load_plugins();
+};

0 comments on commit e36cc11

Please sign in to comment.