<commit_before>var fs = require('fs');
var http = require('http');
var request = require('request');

var util = require("./util.js");

var getBadCommands = function(badCommandsFile, callback) {
	util.log("Bad commands requested.");
	util.readFile(badCommandsFile, function(error, badcommands){
		if (error) {
			callback("Error: \r\n" + error);
		} else {
			// fs.readFileSync returns a buffer. Convert to string here
			callback(null, badcommands.toString());
		}
	});
};

var getLog = function(logName, callback) {
	util.readFile(logName, function(error, logData){
		if (error) {
			callback("Error retrieving log: \r\n" + error);
		} else {
			// fs.readFileSync returns a buffer. Convert to string here
			callback(null, logData.toString());
		}
	});
};

var liveswitch = function(configFileName, callback) {
		var config = {};

		try {
<<<<<<< HEAD
			config = require(configFileName);
			config.testmode = !config.testmode;
=======
			config = JSON.parse(fs.readFileSync(configFile));
			if (config.testmode === true | config.testmode === "true") {
				config.testmode = false;
			} else {
				config.testmode = true;
			}
		} catch(err) {
			callback("Error reading " + configFile + ":\r\n" + err);
>>>>>>> refs/remotes/origin/master
		}
		catch(err) {
			callback("Error reading " + configFileName + ":\r\n" + err);
		}

		try {
			fs.writeFileSync(configFileName, JSON.stringify(config));
			callback(null, config);
		}
		catch (err) {
			callback("Error writing to " + configFileName + ":\r\n" + err);
		}
};

module.exports = {
	badcommands: getBadCommands,
	log: getLog,
	toggletestmode: liveswitch
};<commit_msg>Merging with origin<commit_after>var fs = require('fs');
var http = require('http');
var request = require('request');

var util = require("./util.js");

var getBadCommands = function(badCommandsFile, callback) {
	util.log("Bad commands requested.");
	util.readFile(badCommandsFile, function(error, badcommands){
		if (error) {
			callback("Error: \r\n" + error);
		} else {
			// fs.readFileSync returns a buffer. Convert to string here
			callback(null, badcommands.toString());
		}
	});
};

var getLog = function(logName, callback) {
	util.readFile(logName, function(error, logData){
		if (error) {
			callback("Error retrieving log: \r\n" + error);
		} else {
			// fs.readFileSync returns a buffer. Convert to string here
			callback(null, logData.toString());
		}
	});
};

var liveswitch = function(configFileName, callback) {
		var config = {};

		try {
			config = require(configFileName);
			config.testmode = !config.testmode;
		}
		catch(err) {
			callback("Error reading " + configFileName + ":\r\n" + err);
		}

		try {
			fs.writeFileSync(configFileName, JSON.stringify(config));
			callback(null, config);
		}
		catch (err) {
			callback("Error writing to " + configFileName + ":\r\n" + err);
		}
};

module.exports = {
	badcommands: getBadCommands,
	log: getLog,
	toggletestmode: liveswitch
};
{'fraction_non_alphanumeric': 0.16280653950953677, 'fraction_numerical': 0.0, 'mean_word_length': 3.911371237458194, 'pattern_counts': {'":': 5, '<': 10, '<?xml version=': 0, '>': 10, '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': '5898190', 'n_tokens_mistral': 1064, 'n_tokens_neox': 969, 'n_words': 222}