<commit_before>import * as appRoot from 'app-root-path';
import * as path from 'path';
import { env } from '../env';
import { ensureAbsolutePath } from '../utils/utils';
import { IPublicConfig } from './IPublicConfig';
import { PrivateConfig } from './PrivateConfig';

export function createConfig(props: IPublicConfig): PrivateConfig {
  const config = new PrivateConfig(props);

  config.root = process.env.APP_ROOT || appRoot.path;
  config.defaultCollectionName = 'default';

  if (props.homeDir) {
    config.homeDir = ensureAbsolutePath(props.homeDir, env.SCRIPT_PATH);
  } else {
    config.homeDir = env.SCRIPT_PATH;
  }

  config.modules = [env.FUSE_MODULES];

  if (props.modules) {
    config.modules = config.modules.concat(props.modules).map(item => ensureAbsolutePath(item, env.SCRIPT_PATH));
  }
  if (props.output) {
    config.output = props.output;
  }
  if (props.alias) {
    config.alias = props.alias;
  }
  if (props.tsConfig) {
    if (typeof props.tsConfig === 'string') {
      config.tsConfig = ensureAbsolutePath(props.tsConfig, env.SCRIPT_PATH);
    } else {
      config.tsConfig = props.tsConfig;
    }
  }

  if (props.target) {
    config.target = props.target;
  }
  // allow them by default
  config.allowSyntheticDefaultImports = true;
  if (props.allowSyntheticDefaultImports !== undefined) {
    config.allowSyntheticDefaultImports = props.allowSyntheticDefaultImports;
  }
  config.webIndex = {
    enabled: false,<commit_msg>fix: node_modules relative to fuse.js<commit_after>import * as appRoot from 'app-root-path';
import * as path from 'path';
import { env } from '../env';
import { ensureAbsolutePath, fileExists, pathJoin } from '../utils/utils';
import { IPublicConfig } from './IPublicConfig';
import { PrivateConfig } from './PrivateConfig';

export function createConfig(props: IPublicConfig): PrivateConfig {
  const config = new PrivateConfig(props);

  config.root = process.env.APP_ROOT || appRoot.path;
  config.defaultCollectionName = 'default';

  if (props.homeDir) {
    config.homeDir = ensureAbsolutePath(props.homeDir, env.SCRIPT_PATH);
  } else {
    config.homeDir = env.SCRIPT_PATH;
  }

  config.modules = [env.FUSE_MODULES];

  if (props.modules) {
    config.modules = config.modules.concat(props.modules).map(item => ensureAbsolutePath(item, env.SCRIPT_PATH));
  }
  // make sure we have node_modules if that exists relatively to the script path (fuse.js)
  const relativeNodeModulePath = pathJoin(env.SCRIPT_PATH, 'node_modules');
  if (fileExists(relativeNodeModulePath)) {
    if (!config.modules.find(i => i === relativeNodeModulePath)) {
      config.modules.push(relativeNodeModulePath);
    }
  }

  if (props.output) {
    config.output = props.output;
  }
  if (props.alias) {
    config.alias = props.alias;
  }
  if (props.tsConfig) {
    if (typeof props.tsConfig === 'string') {
      config.tsConfig = ensureAbsolutePath(props.tsConfig, env.SCRIPT_PATH);
    } else {
      config.tsConfig = props.tsConfig;
    }
  }

  if (props.target) {
    config.target = props.target;
  }
  // allow them by default
  config.allowSyntheticDefaultImports = true;
  if (props.allowSyntheticDefaultImports !== undefined) {
    config.allowSyntheticDefaultImports = props.allowSyntheticDefaultImports;
  }
  config.webIndex = {
    enabled: false,
{'fraction_non_alphanumeric': 0.1278648974668275, 'fraction_numerical': 0.0, 'mean_word_length': 3.8352769679300294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '4379256', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1030, 'n_words': 218}