<commit_before>/*eslint no-console: "error" */
'use strict';

const fsOps = require('./fsOps'),
  objOps = require('./objOps');
let result = {};

async function walkDir(path, opt){

  try {

    const pathStats = await fsOps.readInfo(path);

    if (pathStats.isFile()) return true;

    const dirContent = await fsOps.readDir(path);

    for (let i = 0; i < dirContent.length; i++) {

      const name = dirContent[i];
      const contentPath = `${path}/${name}`;

      if (opt && opt.blDir && objOps.isBlacklisted(path, opt.blDir)) break;

      let pathResult = result[path];
      const isFile = await walkDir(contentPath, opt);

      if (isFile === true){

        if (opt && opt.blFiles && objOps.isBlacklisted(name, opt.blFiles)) break;

        if (pathResult) {

          result[path] = ++pathResult;
          //for listing files instead of counting them
          //pathResult.push(name)
          //result[path] = pathResult;
        } else {

          result[path] = 1;
          //for listing files instead of counting them
          //result[path] = [name];
        }
      }
    }

    return result;
  }
  catch(err) {

    console.log('Read error', err);
  }
}

module.exports = walkDir;<commit_msg>issues/2<commit_after>/*eslint no-console: "error" */
'use strict';

const fsOps = require('./fsOps'),
  objOps = require('./objOps');
let result = {};

async function walkDir(path, opt){

  const pathStats = await fsOps.readInfo(path);

  try {

    if (pathStats.isFile()) return true;

    const dirContent = await fsOps.readDir(path);

    for (let i = 0; i < dirContent.length; i++) {

      const name = dirContent[i];
      const contentPath = `${path}/${name}`;

      if (opt && opt.blDir && objOps.isBlacklisted(path, opt.blDir)) break;

      let pathResult = result[path];
      const isFile = await walkDir(contentPath, opt);

      if (isFile === true){

        if (opt && opt.blFiles && objOps.isBlacklisted(name, opt.blFiles)) break;

        if (pathResult) {

          result[path] = ++pathResult;
          //for listing files instead of counting them
          //pathResult.push(name)
          //result[path] = pathResult;
        } else {

          result[path] = 1;
          //for listing files instead of counting them
          //result[path] = [name];
        }
      }
    }

    return result;
  }
  catch(err) {

    console.log(err);
  }
}

module.exports = walkDir;
{'fraction_non_alphanumeric': 0.1470466749277158, 'fraction_numerical': 0.0020652622883106154, 'mean_word_length': 2.3360881542699725, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2792088', 'n_tokens_mistral': 778, 'n_tokens_neox': 746, 'n_words': 195}