<commit_before>'use strict';

const path  = require('path');
const chalk = require('chalk');
const requireDirectory = require('require-directory');

const loadFeatures = require('./load-features');
const Logger       = require('./logger');

class Config {
  constructor(outputStream) {
    this.outputStream = outputStream;
    this.logger = new Config.Logger(outputStream);
    this.base = process.cwd();
  }

  load(configPath) {
    this.configPath = configPath || path.resolve(this.base, './.cucaroo.config.js');
    this.loadFromConfigFile();
    this.loadFeatureFiles();
    this.loadDefinitions();
    this.loadSetupTeardown();
    this.timeout = this.fileAttributes.timeout || this.defaultTimeout();
  }

  loadFromConfigFile() {
    this.fileAttributes = {};
    let message = '`cucaroo.config.js` config file not found. Using default values.'
    this.tryOrWarn(() => {
      this.fileAttributes = this.remap(require(this.configPath));
    }, message);
  }

  loadFeatureFiles() {
    this.features = [];
    this.tryOrWarn(() => {
      this.features = loadFeatures(this.paths().features);
    });
  }

  loadDefinitions() {
    this.stepExports = [];
    this.tryOrWarn(() => {
      let fileMap = requireDirectory(module, this.paths().stepDefinitions);
      this.stepExports = Object.keys(fileMap).map((filename) => {
        return fileMap[filename];
      });
    });
  }

  loadSetupTeardown() {
    this.tryOrWarn(() => {
      this.setup = require(this.paths().suiteSetup);
      this.teardown = require(this.paths().suiteTeardown);
    });
  }

  remap(attributes) {
    return Object.assign(attributes, {
      features: attributes.featuresDirectory
    });
  }

  paths() {
    return Object.assign(this.defaultPaths(), this.fileAttributes);
  }
<commit_msg>default featuresDirectory if config file is present but no featuresDirectory is present<commit_after>'use strict';

const path  = require('path');
const chalk = require('chalk');
const requireDirectory = require('require-directory');

const loadFeatures = require('./load-features');
const Logger       = require('./logger');

class Config {
  constructor(outputStream) {
    this.outputStream = outputStream;
    this.logger = new Config.Logger(outputStream);
    this.base = process.cwd();
  }

  load(configPath) {
    this.configPath = configPath || path.resolve(this.base, './.cucaroo.config.js');
    this.loadFromConfigFile();
    this.loadFeatureFiles();
    this.loadDefinitions();
    this.loadSetupTeardown();
    this.timeout = this.fileAttributes.timeout || this.defaultTimeout();
  }

  loadFromConfigFile() {
    this.fileAttributes = {};
    let message = '`cucaroo.config.js` config file not found. Using default values.'
    this.tryOrWarn(() => {
      this.fileAttributes = this.remap(require(this.configPath));
    }, message);
  }

  loadFeatureFiles() {
    this.features = [];
    this.tryOrWarn(() => {
      this.features = loadFeatures(this.paths().features);
    });
  }

  loadDefinitions() {
    this.stepExports = [];
    this.tryOrWarn(() => {
      let fileMap = requireDirectory(module, this.paths().stepDefinitions);
      this.stepExports = Object.keys(fileMap).map((filename) => {
        return fileMap[filename];
      });
    });
  }

  loadSetupTeardown() {
    this.tryOrWarn(() => {
      this.setup = require(this.paths().suiteSetup);
      this.teardown = require(this.paths().suiteTeardown);
    });
  }

  remap(attributes) {

    return Object.assign(attributes, {
      features: attributes.featuresDirectory || path.resolve(this.base, 'features')
    });
  }

  paths() {
    return Object.assign(this.defaultPaths(), this.fileAttributes);
  }

{'fraction_non_alphanumeric': 0.15432770821992378, 'fraction_numerical': 0.0, 'mean_word_length': 3.427710843373494, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '599330', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1085, 'n_words': 185}