<commit_before>import path from 'path';
import fs from 'fs-extra';

const defaultConfig = {
  plugins: [],
  localPlugins: []
};

let config = Object.assign({}, defaultConfig);

const configFile = path.join(__dirname, '../.rotonde.json');
const contents = fs.readFileSync(configFile, 'utf-8');
config = Object.assign({}, config, JSON.parse(contents));

/**
 * Returns the config.
 */
export function getConfig() {
  return config;
}

/**
 * Returns the path to the plugins directory.
 */
export function getPluginsDirectory() {
  return path.join(__dirname, '../.rotonde_plugins');
}

/**
 * Returns the list of plugins.<commit_msg>Read the config file from the home directory, if not running in development<commit_after>import os from 'os';
import path from 'path';
import fs from 'fs-extra';

const defaultConfig = {
  plugins: [],
  localPlugins: []
};

let config = Object.assign({}, defaultConfig);

const configPath = getConfigPath();
const configFileExists = fs.existsSync(configPath);
if (!configFileExists) {
  fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
}
const contents = fs.readFileSync(configPath, 'utf-8');
config = Object.assign({}, config, JSON.parse(contents));

/**
 * Returns the path to the config file.
 */
function getConfigPath() {
  const configFile = '.rotonde.json';
  if (process.env.NODE_ENV === 'development') {
    return path.resolve(__dirname, `../${configFile}`);
  }
  return path.resolve(os.homedir(), configFile);
}

/**
 * Returns the config.
 */
export function getConfig() {
  return config;
}

/**
 * Returns the path to the plugins directory.
 */
export function getPluginsDirectory() {
  return path.join(__dirname, '../.rotonde_plugins');
}

/**
 * Returns the list of plugins.
{'fraction_non_alphanumeric': 0.15349369988545247, 'fraction_numerical': 0.001718213058419244, 'mean_word_length': 4.442367601246106, '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': '650632', 'n_tokens_mistral': 526, 'n_tokens_neox': 524, 'n_words': 152}