<commit_before>"use strict";

var pkg = require('../package.json');
var fs = require('fs');
var path = require('path');

var debug = require('debug')(pkg.name + ':config');
var extend = require('extend');

var MSG_CONFIG_ENV_NOT_NOT_FOUND = 'Info: environment-specific configuration file not found, creating';

var OTR_PREFIX = process.env.OTR_PREFIX || path.resolve(__dirname, '..');

debug('OTR_PREFIX', OTR_PREFIX);
debug('process.cwd()', process.cwd());

// CONFIG_DIR may be set by environment var, defaults to config
var CONFIG_DIR = process.env.OTR_CONFIG_DIR || path.join(OTR_PREFIX, 'config');
debug('CONFIG_DIR:', CONFIG_DIR);

var defaultsFile = path.join(CONFIG_DIR, 'default.json');
debug('defaultsFile:', defaultsFile);

var config;
let defaults

try {
  defaults = require(defaultsFile);
} 

catch (err) {

  console.error(err.message);

  process.exit(1);
}

config = defaults

debug('defaults:', config);

var nodeEnv = process.env.NODE_ENV || 'development';

var overridesFile = path.join(CONFIG_DIR, nodeEnv + '.json');

debug('overridesFile', overridesFile);

var overrides;

try {
  overrides = require(overridesFile);
}

catch (err) {

  debug('err', err);

  if (err.code === 'MODULE_NOT_FOUND') {
    console.log(MSG_CONFIG_ENV_NOT_NOT_FOUND + ': ' + overridesFile);

    fs.writeFileSync(overridesFile, '{\n\n}');
    overrides = {};
  } else {
    process.exit(1);
  }

}

debug('NODE_ENV overrides:', overrides);

config = extend(true, config, overrides);

debug('config', config);

if (process.env.OTR_CONFIG) {
  var envOverrides = JSON.parse(process.env.OTR_CONFIG);
  config = extend(true, config, envOverrides);
  debug('OTR_CONFIG overrides:', envOverrides);

  debug('config', config)
}

if (config.http.session.secret === defaults.http.session.secret) {
  console.log(`WARNING: The default session "secret" is a misnomer! Use at your own risk!`)
}

module.exports = config;
<commit_msg>remove redundant try/catch<commit_after>"use strict";

var pkg = require('../package.json');
var fs = require('fs');
var path = require('path');

var debug = require('debug')(pkg.name + ':config');
var extend = require('extend');

var MSG_CONFIG_ENV_NOT_NOT_FOUND = 'Info: environment-specific configuration file not found, creating';

var OTR_PREFIX = process.env.OTR_PREFIX || path.resolve(__dirname, '..');

debug('OTR_PREFIX', OTR_PREFIX);
debug('process.cwd()', process.cwd());

// CONFIG_DIR may be set by environment var, defaults to config
var CONFIG_DIR = process.env.OTR_CONFIG_DIR || path.join(OTR_PREFIX, 'config');
debug('CONFIG_DIR:', CONFIG_DIR);

var defaultsFile = path.join(CONFIG_DIR, 'default.json');
debug('defaultsFile:', defaultsFile);

var config;

let defaults = require(defaultsFile);

config = defaults

debug('defaults:', config);

var nodeEnv = process.env.NODE_ENV || 'development';

var overridesFile = path.join(CONFIG_DIR, nodeEnv + '.json');

debug('overridesFile', overridesFile);

var overrides;

try {
  overrides = require(overridesFile);
}

catch (err) {

  debug('err', err);

  if (err.code === 'MODULE_NOT_FOUND') {
    console.log(MSG_CONFIG_ENV_NOT_NOT_FOUND + ': ' + overridesFile);

    fs.writeFileSync(overridesFile, '{\n\n}');
    overrides = {};
  } else {
    process.exit(1);
  }

}

debug('NODE_ENV overrides:', overrides);

config = extend(true, config, overrides);

debug('config', config);

if (process.env.OTR_CONFIG) {
  var envOverrides = JSON.parse(process.env.OTR_CONFIG);
  config = extend(true, config, envOverrides);
  debug('OTR_CONFIG overrides:', envOverrides);

  debug('config', config)
}

if (config.http.session.secret === defaults.http.session.secret) {
  console.log(`WARNING: The default session "secret" is a misnomer! Use at your own risk!`)
}

module.exports = config;

{'fraction_non_alphanumeric': 0.160339792938678, 'fraction_numerical': 0.0007963897000265463, 'mean_word_length': 5.207578253706754, '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': '3458883', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1267, 'n_words': 284}