<commit_before>var fs = require('fs');
var path = require('path');
var glob = require('glob');
var config = require('../src/utils/config');

function processComponent(filepath) {
	var examplesFile = config.getExampleFilename(filepath);
	if (!fs.existsSync(examplesFile)) {
		return null;
	}
	return '{' + [
			'filepath: ' + JSON.stringify(filepath),
			'module: ' + requireIt(filepath),
			'props: require(' + JSON.stringify('!!props!' + filepath) + ')',
			'examples: require(' + JSON.stringify('examples!' + examplesFile) + ')'
		].join(',') + '}';
}

function requireIt(filepath) {
	return 'require(' + JSON.stringify(filepath) + ')';
}

module.exports = function() {};
module.exports.pitch = function() {
	this.cacheable && this.cacheable();

	var componentSources = glob.sync(path.join(config.rootDir, config.components));

	var components = componentSources.map(processComponent);

	// Remove components without examples
	components = components.filter(function(component) {
		return !!component
	});

	return 'module.exports = [' + components.join(',') + ']';
};<commit_msg>Tiny refactoring.<commit_after>var fs = require('fs');
var path = require('path');
var glob = require('glob');
var config = require('../src/utils/config');

function processComponent(filepath) {
	var examplesFile = config.getExampleFilename(filepath);
	if (!fs.existsSync(examplesFile)) {
		return null;
	}
	return '{' + [
			'filepath: ' + JSON.stringify(filepath),
			'module: ' + requireIt(filepath),
			'props: ' + requireIt('!!props!' + filepath),
			'examples: ' + requireIt('examples!' + examplesFile)
		].join(',') + '}';
}

function requireIt(filepath) {
	return 'require(' + JSON.stringify(filepath) + ')';
}

module.exports = function() {};
module.exports.pitch = function() {
	this.cacheable && this.cacheable();

	var componentSources = glob.sync(path.join(config.rootDir, config.components));

	var components = componentSources.map(processComponent);

	// Remove components without examples
	components = components.filter(function(component) {
		return !!component
	});

	return 'module.exports = [' + components.join(',') + ']';
};
{'fraction_non_alphanumeric': 0.1835680751173709, 'fraction_numerical': 0.0, 'mean_word_length': 5.141210374639769, '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': '2947170', 'n_tokens_mistral': 687, 'n_tokens_neox': 650, 'n_words': 127}