<commit_before>/**
 * Load config from a directory into a Sails app
 */

var buildDictionary = require('sails-build-dictionary');
var async = require('async');

var _ = require('lodash');
module.exports = function (sails, dir) {
  async.auto({

    'config/*': function loadOtherConfigFiles (cb) {
      buildDictionary.aggregate({
        dirname: dir,
        exclude: ['locales', 'local.js', 'local.json', 'local.coffee', 'local.litcoffee'],
        excludeDirs: /(locales|env)$/,
        filter: /(.+)\.(js|json|coffee|litcoffee)$/,
        identity: false
      }, cb)
    },

    'config/local' : function loadLocalOverrideFile (cb) {
      buildDictionary.aggregate({
        dirname: dir,
        filter: /local\.(js|json|coffee|litcoffee)$/,
        identity: false
      }, cb);
    },

    'config/env/**': ['config/local', function loadEnvConfigFolder (cb) {
      var env = sails.config.environment || async_data['config/local'].environment || 'development';
      buildDictionary.aggregate({
        dirname: dir + '/env/' + env,
        optional: true,
        filter: /(.+)\.(js|json|coffee|litcoffee)$/,
        identity: false
      }, cb)
    }],

    'config/env/*' : ['config/local', function loadEnvConfigFile (cb, async_data) {
      var env = sails.config.environment || async_data['config/local'].environment || 'development';
      buildDictionary.aggregate({
        dirname: dir + '/env',
        filter: new RegExp("^" + env + "\\.(js|json|coffee|litcoffee)$"),
        optional: true,
        identity: false
      }, cb);
    }]

  }, function (err, async_data) {

    if (err) { throw err; }

    // Merge the configs, with env/*.js files taking precedence over others, and local.js
    // taking precedence over everything
    var configs = _.merge(
        async_data['config/*'],
        async_data['config/env/**'],
        async_data['config/env/*'],
        async_data['config/local']
    );

    sails.config = _.merge(configs, sails.config, function (a, b) {
      if (_.isArray(a)) {
        return a.concat(b);
      }
    });

  });

};<commit_msg>Revert "Update config loader to include env configs"<commit_after>/**
 * Load config from a directory into a Sails app
 */

var buildDictionary = require('sails-build-dictionary');
var _ = require('lodash');
module.exports = function (sails, dir) {
    buildDictionary.aggregate({
        dirname: dir,
        exclude: ['locales', 'local.js', 'local.json', 'local.coffee', 'local.litcoffee'],
        excludeDirs: /(locales|env)$/,
        filter: /(.+)\.(js|json|coffee|litcoffee)$/,
        identity: false
    }, function (err, configs) {
        sails.config = _.merge(configs, sails.config, function (a, b) {
            if (_.isArray(a)) {
                return a.concat(b);
            }
        });
    });
};
{'fraction_non_alphanumeric': 0.1686832740213523, 'fraction_numerical': 0.0, 'mean_word_length': 2.5900383141762453, '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': '2679449', 'n_tokens_mistral': 904, 'n_tokens_neox': 854, 'n_words': 196}