<commit_before>/*jslint node: true, nomen: true, white: true, unparam: true, todo: true*/
/*!
 * Sitegear3
 * Copyright(c) 2014 <NAME>, Sitegear.org
 * MIT Licensed
 */

(function (_, path, fs) {
	"use strict";

	module.exports = function (app, dirname) {
		dirname = dirname || path.join(__dirname, '..', 'viewHelpers');
		return function (request, response, next) {
			app.locals.siteName = app.get('site name');
			app.locals.baseUrl = request.secure ? app.get('https url') : app.get('http url');
			app.locals.now = new Date();

			fs.readdir(dirname, function (error, filenames) {
				// TODO Handle error
				_.each(filenames, function (filename) {
					if (/\.js$/.test(filename)) {
						var name = path.basename(filename, '.js');
						app.locals[name] = require('../viewHelpers/' + filename);
					}
				});
				next();
			});
		};
	};
}(require('lodash'), require('path'), require('fs')));
<commit_msg>Handle error in readdir() callback.<commit_after>/*jslint node: true, nomen: true, white: true, unparam: true, todo: true*/
/*!
 * Sitegear3
 * Copyright(c) 2014 <NAME>, Sitegear.org
 * MIT Licensed
 */

(function (_, path, fs) {
	"use strict";

	module.exports = function (app, dirname) {
		dirname = dirname || path.join(__dirname, '..', 'viewHelpers');
		return function (request, response, next) {
			app.locals.siteName = app.get('site name');
			app.locals.baseUrl = request.secure ? app.get('https url') : app.get('http url');
			app.locals.now = new Date();

			fs.readdir(dirname, function (error, filenames) {
				_.each(filenames, function (filename) {
					if (/\.js$/.test(filename)) {
						var name = path.basename(filename, '.js');
						app.locals[name] = require('../viewHelpers/' + filename);
					}
				});
				next(error);
			});
		};
	};
}(require('lodash'), require('path'), require('fs')));

{'fraction_non_alphanumeric': 0.1963894967177243, 'fraction_numerical': 0.005470459518599562, 'mean_word_length': 3.5049261083743843, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6480986', 'n_tokens_mistral': 713, 'n_tokens_neox': 618, 'n_words': 143}