gulpfile.js
function tree(root) {
	var structure = {};

	var _files = fs.readdirSync(root);
	for(var i=0; i<_files.length; i++) {
		if ((_files[i] !== '.') && (_files[i] !== '..')) {
			var stats = fs.statSync(root + '/' + _files[i]);
			if (stats.isDirectory()) {
				structure[_files[i]] = tree(root + '/' + _files[i]);
			} else if (stats.isFile() && xIsJsFile.test(_files[i])) {
				try {
					structure[_files[i]] = require(root + '/' + _files[i]);
				} catch(err) {
					console.log('Could not load task in: ' + _files[i]);
					console.error(err);
				}
			}
		}
	}

	return structure;
}
function tree(root) {
	var structure = {};

	var _files = fs.readdirSync(root);
	for(var i=0; i<_files.length; i++) {
		if ((_files[i] !== '.') && (_files[i] !== '..')) {
			var stats = fs.statSync(root + '/' + _files[i]);
			if (stats.isDirectory()) {
				structure[_files[i]] = tree(root + '/' + _files[i]);
			} else if (stats.isFile() && xIsJsFile.test(_files[i])) {
				try {
					structure[_files[i]] = require(root + '/' + _files[i]);
				} catch(err) {
					console.log('Could not load task in: ' + _files[i]);
					console.error(err);
				}
			}
		}
	}

	return structure;
}
function tree ( root ) { var structure = { } ; var _files = fs . readdirSync ( root ) ; for ( var i = 0 ; i < _files . length ; i ++ ) { if ( ( _files [ i ] !== '.' ) && ( _files [ i ] !== '..' ) ) { var stats = fs . statSync ( root + '/' + _files [ i ] ) ; if ( stats . isDirectory ( ) ) { structure [ _files [ i ] ] = tree ( root + '/' + _files [ i ] ) ; } else if ( stats . isFile ( ) && xIsJsFile . test ( _files [ i ] ) ) { try { structure [ _files [ i ] ] = require ( root + '/' + _files [ i ] ) ; } catch ( err ) { console . log ( 'Could not load task in: ' + _files [ i ] ) ; console . error ( err ) ; } } } } return structure ; }
Get a tree structure from a directory with given root.  Returns required files if files is .js.

@param {string} root		The starting directory.
@returns {Object}		The structure.
Get a tree structure from a directory with given root . Returns required files if files is . js .