<commit_before>import path from 'path';
import serverRequire from '../utils/server-require';

export default function loadCustomPresets({ configDir }) {
  const presets = serverRequire(path.resolve(configDir, 'presets'));
  const main = serverRequire(path.resolve(configDir, 'main'));

  return []
    .concat(presets || [])
    .concat(main ? main.presets || [] : [])
    .concat(main || []);
}<commit_msg>ADD fail condition when users migrate partially to triconfig also for presets.js<commit_after>import path from 'path';
import dedent from 'ts-dedent';
import serverRequire from '../utils/server-require';

const toArray = a => (a ? [].concat(a) : a);

export default function loadCustomPresets({ configDir }) {
  const presets = serverRequire(path.resolve(configDir, 'presets'));
  const main = serverRequire(path.resolve(configDir, 'main'));

  if (presets && main) {
    throw new Error(dedent`
      You have both a "main.js" and a "presets.js", remove the "presets.js" file from your configDir (${path.resolve(
        configDir,
        'presets'
      )})`);
  }

  return [...(toArray(main ? main.presets : presets) || [])];
}
{'fraction_non_alphanumeric': 0.15452151009657594, 'fraction_numerical': 0.0, 'mean_word_length': 4.135135135135135, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3424012', 'n_tokens_mistral': 349, 'n_tokens_neox': 344, 'n_words': 96}