<commit_before>var path = require('path');
var fs = require('fs');

exports.load = function (y, config, messages, cron, logger, pluginsDir) {
	if (path.existsSync(pluginsDir)) {
		var files = fs.readdirSync(pluginsDir);
		for (var i in files) {
			require(pluginsDir + '/' + files[i]).init(y, config, messages, cron, logger);
			logger.info('plugin \'' + files[i] + '\' initialized');
		}
	}
};<commit_msg>Loading only plugins enabled in the config file<commit_after>var path = require('path');
var fs = require('fs');

exports.load = function (y, config, messages, cron, logger, pluginsDir) {
	if (path.existsSync(pluginsDir)) {
		if (Array.isArray(config.plugins)) {
			for (var i = 0; i < config.plugins.length; i++) {
				var filePath = path.join(pluginsDir, config.plugins[i]);

				if (path.existsSync(filePath + '.js')) {
					require(filePath).init(y, config, messages, cron, logger);
					logger.info('plugin \'' + config.plugins[i] + '\' initialized');
				}
			}

		} else {
			if (config.plugins === true) {
				var files = fs.readdirSync(pluginsDir);
				for (var i in files) {
					if (/\.js$/.exec(files[i])) {
						require(pluginsDir + '/' + files[i]).init(y, config, messages, cron, logger);
						logger.info('plugin \'' + files[i] + '\' initialized');
					}
				}
			}
		}
	}
};
{'fraction_non_alphanumeric': 0.18706697459584296, 'fraction_numerical': 0.0007698229407236335, 'mean_word_length': 3.5454545454545454, 'pattern_counts': {'":': 0, '<': 4, '<?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': '2703955', 'n_tokens_mistral': 503, 'n_tokens_neox': 433, 'n_words': 103}