<commit_before>import fs from 'fs';
import path from 'path';
import makeDebug from 'debug';
import deepAssign from 'deep-assign';

const debug = makeDebug('feathers:configuration');
const separator = path.sep;

export default module.exports = function (root, configFolder = 'config', deep = true) {
  return function() {
    const app = this;
    const env = app.settings.env;
    const convert = current => {
      const result = Array.isArray(current) ? [] : {};

      Object.keys(current).forEach(name => {
        let value = current[name];

        if(typeof value === 'object' && value !== null) {
          value = convert(value);
        }

        if(typeof value === 'string') {
          if(value.indexOf('\\') === 0) {
            value = value.replace('\\', '');
          } else {
            if(process.env[value]) {
              value = process.env[value];
            } else if(value.indexOf('.') === 0 || value.indexOf('..') === 0) {
              // Make relative paths absolute
              value = path.resolve(
                path.join(root, configFolder),
                value.replace(/\//g, separator)
              );
            }
          }
        }

        result[name] = value;
      });

      return result;
    };

    let config = convert(require(path.join(root, configFolder, 'default')));

    debug(`Initializing configuration for ${env} environment`);

    // Dev is our default development. For everything else extend the default
    if(env !== 'development') {
      const envConfig = path.join(root, configFolder, env);
      // We can use sync here since configuration only happens once at startup
      if(fs.existsSync(`${envConfig}.js`) || fs.existsSync(`${envConfig}.json`)) {
        config = deep ? deepAssign(config, convert(require(envConfig))) :
          Object.assign(config, convert(require(envConfig)));
      } else {
        debug(`Configuration file for ${env} environment not found at ${envConfig}`);
      }<commit_msg>Remove check for development mode (#21)<commit_after>import fs from 'fs';
import path from 'path';
import makeDebug from 'debug';
import deepAssign from 'deep-assign';

const debug = makeDebug('feathers:configuration');
const separator = path.sep;

export default module.exports = function (root, configFolder = 'config', deep = true) {
  return function() {
    const app = this;
    const env = app.settings.env;
    const convert = current => {
      const result = Array.isArray(current) ? [] : {};

      Object.keys(current).forEach(name => {
        let value = current[name];

        if(typeof value === 'object' && value !== null) {
          value = convert(value);
        }

        if(typeof value === 'string') {
          if(value.indexOf('\\') === 0) {
            value = value.replace('\\', '');
          } else {
            if(process.env[value]) {
              value = process.env[value];
            } else if(value.indexOf('.') === 0 || value.indexOf('..') === 0) {
              // Make relative paths absolute
              value = path.resolve(
                path.join(root, configFolder),
                value.replace(/\//g, separator)
              );
            }
          }
        }

        result[name] = value;
      });

      return result;
    };

    let config = convert(require(path.join(root, configFolder, 'default')));

    debug(`Initializing configuration for ${env} environment`);

    const envConfig = path.join(root, configFolder, env);
    // We can use sync here since configuration only happens once at startup
    if(fs.existsSync(`${envConfig}.js`) || fs.existsSync(`${envConfig}.json`)) {
      config = deep ? deepAssign(config, convert(require(envConfig))) :
        Object.assign(config, convert(require(envConfig)));
    } else {
      debug(`Configuration file for ${env} environment not found at ${envConfig}`);
{'fraction_non_alphanumeric': 0.1487325400931195, 'fraction_numerical': 0.0020693222969477496, 'mean_word_length': 2.3567708333333335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2915071', 'n_tokens_mistral': 1049, 'n_tokens_neox': 1023, 'n_words': 280}