Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

nervous now strips nervous_plugin_ from the sub namespace that gets s…

…ent to graphite, it's also no necessary for testing
  • Loading branch information...
commit 18e3fc12721652a8f7096ff3a5c65c9483c54f0f 1 parent dcd29c2
Geoff Flarity authored
Showing with 29 additions and 16 deletions.
  1. +15 −14 lib/nervous.js
  2. +14 −2 plugins/test.js
View
29 lib/nervous.js
@@ -4,9 +4,6 @@ var path = require('path');
var steamlogger_helper = require('./streamlogger_helper');
//code
-
-
-
var load_plugins = function () {
var full_path_of_config = require.resolve( '../conf/nervous.json' );
debugger;
@@ -24,18 +21,22 @@ var load_plugins = function () {
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 ) {
+ 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 ) );
- }
- } );
- } );
+ entries = entries || [];
+ entries.forEach(function(entry) {
+ var plugin = full_plugins_path + '/' + entry;
+ fs.stat(plugin, function(err, stats) {
+ if (stats.isDirectory()) {
+
+ //if there's a nervous_plugin_ in our module name, strip it
+ var subspace = entry.replace(/^nervous_plugin_/, '');
+
+ //load the plugin and give it a sub namespace, aka subspace
+ require(plugin)(axon_factory(subspace));
+ }
+ });
+ });
}
View
16 plugins/test.js
@@ -7,11 +7,23 @@ var usage = 'Usage: node test.js <plugin_name>';
if ( process.argv[2] ) {
+ //strip the nervous_plugin from in front if its there
+ var subspace = process.argv[2].replace(/^nervous_plugin_/, '');
+
try {
- require( process.argv[2] )( axon_factory( process.argv[2] ) );
+ require( process.argv[2] )( axon_factory( subspace ) );
} catch ( e ) {
- console.log( usage );
+ //we also support dropping the nervous_plugin_ for testing:
+ try {
+ require( 'nervous_plugin_' + process.argv[2] )( axon_factory( subspace ) );
+ }
+ catch ( e ) {
+ //finally, usage and exit code 1!
+ console.log( usage );
+ process.exit(1);
+ }
+
}
}
else {
Please sign in to comment.
Something went wrong with that request. Please try again.