Skip to content

Instantly share code, notes, and snippets.

@darrenkopp
Forked from anonymous/gist:374485
Created April 21, 2010 22:31
Show Gist options
  • Save darrenkopp/374488 to your computer and use it in GitHub Desktop.
Save darrenkopp/374488 to your computer and use it in GitHub Desktop.
var fs = require('fs'),
sys = require('sys');
fs.readdir('./', function(err, files) {
if (err) {
throw err;
}
sys.puts('callback from files ' + files.length);
return;
var portNum = 8000;
for (var i = 0; i < files.length; i++) {
var splitName = files[i].split('.');
if (splitName.length == 2 &&
splitName[1] == 'js') {
var module = require('./' + splitName[0]);
if (module.registerServer != null) {
sys.puts(splitName[0] + ' using ' + portNum);
module.registerServer(portNum++);
}
else {
sys.puts(splitName[0] + ' does not contain registerServer!');
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment