<commit_before>var
	es          = require('event-stream'),
	Lintspaces  = require('lintspaces'),
	PluginError = require('gulp-util').PluginError,
	colors      = require('gulp-util').colors
;

module.exports = function(options) {
	var lintspaces = new Lintspaces(options || {});

	return es.through(function(file) {
		if (file.isNull()) {
			return this.emit('data', file);
		}

		lintspaces.validate(file.path);
		file.lintspaces = lintspaces.getInvalidLines(file.path);

		// HACK: Clean-up the cache for re-validation
		delete lintspaces._invalid[file.path];

		return this.emit('data', file);
	});
};

module.exports.reporter = function() {
	return es.through(function(file) {
		if (file.isNull()) {
			return this.emit('data', file);
		}

		if (file.lintspaces && Object.keys(file.lintspaces).length) {
			for (var line in file.lintspaces) {
				file.lintspaces[line].forEach(function(error) {
					console.error(
						'[%s] %s in (%s:%d)\n',
						colors.green('gulp-lintspaces'),
						colors.red(error.message),
						file.path,
						line
					);
				});
			}
		}

		if (Object.keys(file.lintspaces).length) {
			this.emit('error', new PluginError("lint-spaces", "Failed linting spaces"));
		}

		return this.emit('data', file);
	});
}<commit_msg>Use gulp's logging system and fix error message<commit_after>var
	es          = require('event-stream'),
	Lintspaces  = require('lintspaces'),
	PluginError = require('gulp-util').PluginError,
	log         = require('gulp-util').log,
	colors      = require('gulp-util').colors
;

module.exports = function(options) {
	var lintspaces = new Lintspaces(options || {});

	return es.through(function(file) {
		if (file.isNull()) {
			return this.emit('data', file);
		}

		lintspaces.validate(file.path);
		file.lintspaces = lintspaces.getInvalidLines(file.path);

		// HACK: Clean-up the cache for re-validation
		delete lintspaces._invalid[file.path];

		return this.emit('data', file);
	});
};

module.exports.reporter = function() {
	return es.through(function(file) {
		if (file.isNull()) {
			return this.emit('data', file);
		}

		if (file.lintspaces && Object.keys(file.lintspaces).length) {
			for (var line in file.lintspaces) {
				file.lintspaces[line].forEach(function(error) {
					log(
						'gulp-lintspaces',
						[
							gutil.colors.red(error.message),
							'in',
							file.path + ':' + line
						].join(' ')
					);
				});
			}
		}

		if (Object.keys(file.lintspaces).length) {
			this.emit('error', new PluginError("gulp-lintspaces", "Found spacing errors"));
		}

		return this.emit('data', file);
	});
}
{'fraction_non_alphanumeric': 0.1706656346749226, 'fraction_numerical': 0.0, 'mean_word_length': 3.4037478705281092, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6103261', 'n_tokens_mistral': 1044, 'n_tokens_neox': 860, 'n_words': 155}