view modules.js @ 40:741110cdcfcf

Avoid exposing unneeded object.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 20 Feb 2011 14:32:49 +0100
parents b2faacfefb90
children bc717575e66a
line wrap: on
line source

var modules = exports;

var files = require('fs').readdirSync('modules');
var regex = /^mod_.*\.js/;

for (var i in files) {
	var file = files[i];
	if (!regex.test(file))
		continue;

	var module = require('./modules/' + files[i]);
	for (var j in module) {
		if (typeof modules[j] != 'undefined')
			console.log('WARNING: module '+j+' already loaded.');

		modules[j] = module[j];
	}
}