<commit_before>var _ = require('lodash');
var dirHas = require('./dirHas');
var fs = require('fs');
var path = require('path');
var stringOrArray = require('./stringOrArray');
var transformDeps = require('transform-jest-deps');
var unwin = require('unwin');
var webpackInfo = require('./webpackInfo');

var defaultAliases = {};
var defaultFallbackDirs = [];
var defaultFileExtensions = ['', '.webpack.js', '.web.js', '.js', '.json'];
var defaultModules = ['node_modules'];
var defaultModulesDirs = ['node_modules', 'web_modules'];

var aliases;
var fileExtensions;
var moduleDirs;
var webpackSettings;

function ensureWebpackInfo(filename) {
  if (webpackSettings) {
    return;
  }

  webpackSettings = webpackInfo.read({filename: filename});
  var resolveConfig = webpackSettings.config.resolve;
  var webpackDir = path.dirname(webpackSettings.file);
  aliases = resolveConfig.alias || defaultAliases;
  fileExtensions = resolveConfig.extensions || defaultFileExtensions;
  moduleDirs = resolveConfig.modules || defaultModules;

  if (!resolveConfig.modules) {
    // webpack 1.x path names
    var rootDirs = stringOrArray(resolveConfig.root);
    var modDirs = stringOrArray(resolveConfig.modulesDirectories) || defaultModulesDirs;
    var fallbackDirs = stringOrArray(resolveConfig.fallback) || defaultFallbackDirs;
    moduleDirs = _.union(rootDirs, modDirs, fallbackDirs);
  }

  moduleDirs = moduleDirs.map(function(dir) {
    return path.resolve(webpackDir, dir);
  })<commit_msg>Adjust webpack v2 detection slighty so that a default resolve.modules is still possible<commit_after>var _ = require('lodash');
var dirHas = require('./dirHas');
var fs = require('fs');
var path = require('path');
var stringOrArray = require('./stringOrArray');
var transformDeps = require('transform-jest-deps');
var unwin = require('unwin');
var webpackInfo = require('./webpackInfo');

var defaultAliases = {};
var defaultFallbackDirs = [];
var defaultFileExtensions = ['', '.webpack.js', '.web.js', '.js', '.json'];
var defaultModules = ['node_modules'];
var defaultModulesDirs = ['node_modules', 'web_modules'];

var aliases;
var fileExtensions;
var moduleDirs;
var webpackSettings;

function ensureWebpackInfo(filename) {
  if (webpackSettings) {
    return;
  }

  webpackSettings = webpackInfo.read({filename: filename});
  var resolveConfig = webpackSettings.config.resolve;
  var webpackDir = path.dirname(webpackSettings.file);
  aliases = resolveConfig.alias || defaultAliases;
  fileExtensions = resolveConfig.extensions || defaultFileExtensions;
  moduleDirs = resolveConfig.modules || defaultModules;

  if (!resolveConfig.modules && resolveConfig.root) {
    // webpack 1.x path names
    var rootDirs = stringOrArray(resolveConfig.root);
    var modDirs = stringOrArray(resolveConfig.modulesDirectories) || defaultModulesDirs;
    var fallbackDirs = stringOrArray(resolveConfig.fallback) || defaultFallbackDirs;
    moduleDirs = _.union(rootDirs, modDirs, fallbackDirs);
  }

  moduleDirs = moduleDirs.map(function(dir) {
    return path.resolve(webpackDir, dir);
  })
{'fraction_non_alphanumeric': 0.13077423552374756, 'fraction_numerical': 0.0009759271307742355, 'mean_word_length': 5.528662420382165, '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': '5131411', 'n_tokens_mistral': 909, 'n_tokens_neox': 902, 'n_words': 207}