<commit_before>var jf = require('jsonfile')
var log = require('better-console')
var path = require('path')

var CONFIG_FILENAME = 'mango.json'
var CONFIG_FILENAME_LOCAL = 'mango.local.json'


/**
 * Config helper
 *
 * @param  {string} path to a folder with the config file
 */
var Config = module.exports = function(folder) {
	this.dir = folder || process.cwd()
	this.defaults = {
		"src_folder": ".",
		"dist_folder": "dist",
		"styles": null,
		"scripts": null,
		"images": null,
		"static": null,
		"templates": null,
		"dependencies": null,
		"watch": null
	}
}

/**
 * Get config object
 * @param  {boolean} filter local config
 * @return {Object} config object
 */
Config.prototype.get = function(filterLocal) {
	var k
	var config = {}
	var config_main
	var config_local

	try {
		config_main = jf.readFileSync(path.resolve(this.dir, CONFIG_FILENAME), { throws: true })
		config_local = jf.readFileSync(path.resolve(this.dir, CONFIG_FILENAME_LOCAL), { throws: false })
	} catch(e){
		log.error('Config file in invalid format: ', e.message)
	}

	if(!config_main){
		log.error('Cannot load the config file mango.json')
		process.exit(1)
	}

	if(this.defaults) {
		for(k in this.defaults) {
			config[k] = this.defaults[k]
		}
	}

	if(config_main) {
		for(k in config_main) {
			config[k] = config_main[k]
		}
	}

	if(config_local) {
		for(k in config_local) {
			config[k] = config_local[k]
		}
	}

	return config
}

/**
 * Save config state to file
 * @param  {Object} config state to save
 */
Config.prototype.save = function(config) {
	// Filter out null values
	for(var prop in config){
		if(config.hasOwnProperty(prop) && !config[prop]){
			delete config[prop];
		}
	}
	// Write to file
	jf.spaces = 2 // set proper formatting
	jf.writeFile(path.resolve(this.dir, CONFIG_FILENAME), config, function (err) {
		if(err) log.error(err)
	})
}<commit_msg>Config: do not load local config when requested<commit_after>var jf = require('jsonfile')
var log = require('better-console')
var path = require('path')

var CONFIG_FILENAME = 'mango.json'
var CONFIG_FILENAME_LOCAL = 'mango.local.json'


/**
 * Config helper
 *
 * @param  {string} path to a folder with the config file
 */
var Config = module.exports = function(folder) {
	this.dir = folder || process.cwd()
	this.defaults = {
		"src_folder": ".",
		"dist_folder": "dist",
		"styles": null,
		"scripts": null,
		"images": null,
		"static": null,
		"templates": null,
		"dependencies": null,
		"watch": null
	}
}

/**
 * Get config object
 * @param  {boolean} filter local config
 * @return {Object} config object
 */
Config.prototype.get = function(filterLocal) {
	var k
	var config = {}
	var config_main
	var config_local

	try {
		config_main = jf.readFileSync(path.resolve(this.dir, CONFIG_FILENAME), { throws: true })
		config_local = jf.readFileSync(path.resolve(this.dir, CONFIG_FILENAME_LOCAL), { throws: false })
	} catch(e){
		log.error('Config file in invalid format: ', e.message)
	}

	if(!config_main){
		log.error('Cannot load the config file mango.json')
		process.exit(1)
	}

	if(this.defaults) {
		for(k in this.defaults) {
			config[k] = this.defaults[k]
		}
	}

	if(config_main) {
		for(k in config_main) {
			config[k] = config_main[k]
		}
	}

	if(config_local && (filterLocal === undefined || filterLocal !== true)) {
		for(k in config_local) {
			config[k] = config_local[k]
		}
	}

	return config
}

/**
 * Save config state to file
 * @param  {Object} config state to save
 */
Config.prototype.save = function(config) {
	// Filter out null values
	for(var prop in config){
		if(config.hasOwnProperty(prop) && !config[prop]){
			delete config[prop];
		}
	}
	// Write to file
	jf.spaces = 2 // set proper formatting
	jf.writeFile(path.resolve(this.dir, CONFIG_FILENAME), config, function (err) {
		if(err) log.error(err)
	})
}
{'fraction_non_alphanumeric': 0.15051221434200157, 'fraction_numerical': 0.0010506960861570791, 'mean_word_length': 3.8447837150127224, 'pattern_counts': {'":': 18, '<': 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': '3585979', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1344, 'n_words': 331}