<commit_before>const sysPath = require('path');
const chai = require('chai');
const {Readable} = require('stream');
chai.should();
const {promisify} = require('util');
const rimraf = require('rimraf');

const root = sysPath.join(__dirname, "fixtures");
const readdirp = require('..');

const fs = require('fs').promises;
let testCount = 0;
let currPath;

const read = async (options) => {
  return await readdirp.promise(currPath, options);
};

const touch = async (files=[], dirs=[]) => {
  for (const name of files) {
    await fs.writeFile(sysPath.join(currPath, name), `${Date.now()}`);
  }
  for (const dir of dirs) {
    await fs.mkdir(sysPath.join(currPath, dir));
  }
}

beforeEach(async () => {
  testCount++;
  currPath = sysPath.join(__dirname, 'fixtures', testCount.toString())
  await promisify(rimraf)(currPath);
  await fs.mkdir(currPath);
});

afterEach(async () => {
  await promisify(rimraf)(currPath);
});

describe('basic', () => {
  it('reads directory', async () => {
    const files = ['a.txt', 'b.txt', 'c.txt'];
    await touch(files);
    const res = await read();
    res.should.have.lengthOf(files.length);
  });
});

describe('entryType', () => {
  const files = ['a.txt', 'b.txt', 'c.txt'];
  const dirs = ['d', 'e', 'f', 'g'];

  it('files', async () => {
    await touch(files, dirs);
    const res = await read({entryType: 'files'});
    res.should.have.lengthOf(files.length);
    res.map(e => e.basename).should.deep.equal(files);
  });
<commit_msg>Fix promises.<commit_after>const sysPath = require('path');
const chai = require('chai');
const {Readable} = require('stream');
chai.should();
const {promisify} = require('util');
const rimraf = require('rimraf');

const root = sysPath.join(__dirname, "fixtures");
const readdirp = require('..');

const fs = require('fs');
let testCount = 0;
let currPath;

const read = async (options) => {
  return await readdirp.promise(currPath, options);
};

const touch = async (files=[], dirs=[]) => {
  for (const name of files) {
    await promisify(fs.writeFile)(sysPath.join(currPath, name), `${Date.now()}`);
  }
  for (const dir of dirs) {
    await promisify(fs.mkdir)(sysPath.join(currPath, dir));
  }
}

beforeEach(async () => {
  testCount++;
  currPath = sysPath.join(__dirname, 'fixtures', testCount.toString())
  await promisify(rimraf)(currPath);
  await promisify(fs.mkdir)(currPath);
});

afterEach(async () => {
  await promisify(rimraf)(currPath);
});

describe('basic', () => {
  it('reads directory', async () => {
    const files = ['a.txt', 'b.txt', 'c.txt'];
    await touch(files);
    const res = await read();
    res.should.have.lengthOf(files.length);
  });
});

describe('entryType', () => {
  const files = ['a.txt', 'b.txt', 'c.txt'];
  const dirs = ['d', 'e', 'f', 'g'];

  it('files', async () => {
    await touch(files, dirs);
    const res = await read({entryType: 'files'});
    res.should.have.lengthOf(files.length);
    res.map(e => e.basename).should.deep.equal(files);
  });

{'fraction_non_alphanumeric': 0.20855614973262032, 'fraction_numerical': 0.0006684491978609625, 'mean_word_length': 4.325622775800712, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '1943396', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1056, 'n_words': 231}