<commit_before>'use strict';

var fs    = require('fs-extra');
var del   = require('del');
var path  = require('path');
var ncp   = require('ncp').ncp;
var chalk = require('chalk');

var CONFIG_FILE = '/.cartridgecli';

var paths = {
	project: path.resolve('../../'),
	config: path.resolve('../../_config')
};

var slateCliApi = {};

// Checks if the project has been set up with slate
function hasSlate() {
	try {
		fs.accessSync(paths.project + CONFIG_FILE, fs.R_OK | fs.W_OK);
	} catch(err) {
		return false;
	}

	return true;
}

function modifyJsonFile(path, transform, callback) {
	fs.readJson(path, function (err, fileContents) {
		if(!err) {
			fileContents = transform(fileContents);
			fs.writeJson(path, fileContents, callback);
		} else {
			callback(err);
		}
	});
}

var modulePrototype = {};

// Adds the specified module to the .slaterc file
slateCliApi.addToSlaterc = function addToSlaterc(module, callback) {
	modifyJsonFile(paths.project + CONFIG_FILE, function addModule(data) {
		if(!data.hasOwnProperty('modules')) {
			data.modules = [];
		}

		data.modules.push(module);

		return data;
	}, callback);
};

// Removes the specified module from the .slaterc file
slateCliApi.removeFromSlaterc = function removeFromSlaterc(module, callback) {
	// TODO: implement
};

slateCliApi.ensureSlateExists = function ensureSlateExists() {
	if(!hasSlate()) {
		console.error(chalk.red('Slate is not set up in this directory. Please set it up first before installing this module'));
		process.exit(1);
	}
};

// Modify the project configuration (project.json) with a transform function
slateCliApi.modifyProjectConfig = function modifyProjectConfig(transform, callback) {
	modifyJsonFile(paths.config + '/project.json', transform, callback);
};

// Add configuration files to the project _config directory for this module
slateCliApi.addModuleConfig = function addModuleConfig(configPath, callback) {
	ncp(configPath, paths.config, callback);
};

// Remove configuration files from the project _config directory for this module
slateCliApi.removeModuleConfig = function removeModuleConfig() {
	// TODO: implement
};

module.exports = slateCliApi;
<commit_msg>Update the internal names for the cli module<commit_after>'use strict';

var fs    = require('fs-extra');
var del   = require('del');
var path  = require('path');
var ncp   = require('ncp').ncp;
var chalk = require('chalk');

var CONFIG_FILE = '/.cartridgecli';

var paths = {
	project: path.resolve('../../'),
	config: path.resolve('../../_config')
};

var cartridgeApi = {};

// Checks if the project has been set up with slate
function hasSlate() {
	try {
		fs.accessSync(paths.project + CONFIG_FILE, fs.R_OK | fs.W_OK);
	} catch(err) {
		return false;
	}

	return true;
}

function modifyJsonFile(path, transform, callback) {
	fs.readJson(path, function (err, fileContents) {
		if(!err) {
			fileContents = transform(fileContents);
			fs.writeJson(path, fileContents, callback);
		} else {
			callback(err);
		}
	});
}

cartridgeApi.ensureCartridgeExists = function ensureCartridgeExists() {
	if(!hasSlate()) {
		console.error(chalk.red('Slate is not set up in this directory. Please set it up first before installing this module'));
		process.exit(1);
	}
};

// Adds the specified module to the .slaterc file
cartridgeApi.addToRc = function addToRc(module, callback) {
	modifyJsonFile(paths.project + CONFIG_FILE, function addModule(data) {
		if(!data.hasOwnProperty('modules')) {
			data.modules = [];
		}

		data.modules.push(module);

		return data;
	}, callback);
};

// Removes the specified module from the .slaterc file
cartridgeApi.removeFromRc = function removeFromRc(module, callback) {
	// TODO: implement
};

// Modify the project configuration (project.json) with a transform function
cartridgeApi.modifyProjectConfig = function modifyProjectConfig(transform, callback) {
	modifyJsonFile(paths.config + '/project.json', transform, callback);
};

// Add configuration files to the project _config directory for this module
cartridgeApi.addModuleConfig = function addModuleConfig(configPath, callback) {
	ncp(configPath, paths.config, callback);
};

// Remove configuration files from the project _config directory for this module
cartridgeApi.removeModuleConfig = function removeModuleConfig() {
	// TODO: implement
};

module.exports = cartridgeApi;

{'fraction_non_alphanumeric': 0.128690036900369, 'fraction_numerical': 0.00046125461254612545, 'mean_word_length': 4.625162127107653, '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': '4052943', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1320, 'n_words': 363}