<commit_before>var path = require('path');
var minimist = require('minimist');
var utils = require('./lib/utils');
var deepExtend = require('deep-extend');
var seek = require('flatnest').seek;

var isWin = process.platform === 'win32';
var etc = '/etc';
var home = isWin ? process.env.USERPROFILE : process.env.HOME;

module.exports = function (name, defaults, aliases, argv) {
  if (typeof name !== 'string') {
    throw new Error('name argument must be a string');
  }

  defaults = defaults || {};
  aliases = aliases || {};

  argv = utils.argv(argv || minimist(process.argv.splice(2), {
    alias: aliases 
  }), aliases);

  var env = utils.env(name + '_');

  function removeDuplicates (item, index, list) {
    return item && list.indexOf(item) === index;
  }

  function removeFalsy (item) {
    return !!item;
  }

  function loadConfig (filePath) {
    var content = utils.file(filePath);
    if (!content) { return null; }
    return utils.parse(content);
  }

  var configs = [
    !isWin  &&  path.join(etc, name, 'config'),
    !isWin  &&  path.join(etc, name + 'rc'),
    home    &&  path.join(home, '.config', name, 'config'),
    home    &&  path.join(home, '.config', name),
    home    &&  path.join(home, '.' + name, 'config'),
    home    &&  path.join(home, '.' + name + 'rc'),
                utils.find('.' + name + 'rc'),
                argv.config
  ]
    .filter(removeDuplicates)
    .map(loadConfig)
    .filter(removeFalsy);

  var conf = deepExtend.apply(null, [defaults].concat(configs, env, argv));

  conf.get = seek.bind(null, conf);

  return conf;<commit_msg>normalize key paths<commit_after>var path = require('path');
var minimist = require('minimist');
var utils = require('./lib/utils');
var deepExtend = require('deep-extend');
var seek = require('flatnest').seek;

var isWin = process.platform === 'win32';
var etc = '/etc';
var home = isWin ? process.env.USERPROFILE : process.env.HOME;

module.exports = function (name, defaults, aliases, argv) {
  if (typeof name !== 'string') {
    throw new Error('name argument must be a string');
  }

  defaults = defaults || {};
  aliases = aliases || {};

  argv = utils.argv(argv || minimist(process.argv.splice(2), {
    alias: aliases 
  }), aliases);

  var env = utils.env(name + '_');

  function removeDuplicates (item, index, list) {
    return item && list.indexOf(item) === index;
  }

  function removeFalsy (item) {
    return !!item;
  }

  function loadConfig (filePath) {
    var content = utils.file(filePath);
    if (!content) { return null; }
    return utils.parse(content);
  }

  var configFiles = [
    !isWin  &&  path.join(etc, name, 'config'),
    !isWin  &&  path.join(etc, name + 'rc'),
    home    &&  path.join(home, '.config', name, 'config'),
    home    &&  path.join(home, '.config', name),
    home    &&  path.join(home, '.' + name, 'config'),
    home    &&  path.join(home, '.' + name + 'rc'),
                utils.find('.' + name + 'rc'),
                argv.config
  ]
    .filter(removeDuplicates);

  var configs = configFiles
    .map(loadConfig)
    .filter(removeFalsy);

  var conf = deepExtend.apply(null, [utils.normalize(defaults)].concat(configs, env, argv));

  conf.configs = configFiles;
  conf.get = seek.bind(null, conf);

  return conf;
{'fraction_non_alphanumeric': 0.17362168748096254, 'fraction_numerical': 0.0018275967103259215, 'mean_word_length': 3.110137672090113, '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': '28404', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1079, 'n_words': 264}