<commit_before>'use strict';

const fs = require('fs');
const path = require('path');
const rimraf = require('rimraf');

const root = path.join(__dirname, '../temp');

function filePath(p) {
  return path.join(root, p);
}

try {
  fs.mkdirSync(root);
} catch (e) {
  // do nothing
}

module.exports = {
  createFile(p, initialContent) {
    fs.writeFileSync(filePath(p), initialContent);
  },
  makeDirectory(p) {
    fs.mkdirSync(filePath(p));
  },
  path(p) {
    return path.join(root, p);
  },
  clean() {
    rimraf.sync(path.join(root, '*'));
  },
  previewRegExp(pathname) {
    let basename = path.basename(pathname);
    let regexStr = `^<!DOCTYPE html><html><head><meta charset="UTF-8"><title>${basename}<\/title><style>(.|\n)*<\/style><\/head><body><div id="app"><\/div><script>(.|\n)*<\/script><\/body><\/html>$`;
    return new RegExp(regexStr);
  }
};<commit_msg>Create and clean the test root directory when starting test cases<commit_after>'use strict';

const fs = require('fs');
const path = require('path');
const rimraf = require('rimraf');

const root = path.join(__dirname, '../temp');

function filePath(p) {
  return path.join(root, p);
}


const helper = {
  createFile(p, initialContent) {
    fs.writeFileSync(filePath(p), initialContent);
  },
  makeDirectory(p) {
    try {
      fs.mkdirSync(filePath(p));
    } catch (e) {
      if (e.code !== 'EEXIST') {
        throw e;
      }
    }
  },
  path(p) {
    return path.join(root, p);
  },
  createRootDirectory() {
    try {
      fs.mkdirSync(root);
    } catch (e) {
      // do nothing
    }
  },
  clean() {
    rimraf.sync(path.join(root, '*'));
  },
  previewRegExp(pathname) {
    let basename = path.basename(pathname);
    let regexStr = `^<!DOCTYPE html><html><head><meta charset="UTF-8"><title>${basename}<\/title><style>(.|\n)*<\/style><\/head><body><div id="app"><\/div><script>(.|\n)*<\/script><\/body><\/html>$`;
    return new RegExp(regexStr);
  }
};

helper.createRootDirectory();
helper.clean();

module.exports = helper;
{'fraction_non_alphanumeric': 0.21167161226508407, 'fraction_numerical': 0.0009891196834817012, 'mean_word_length': 3.5977272727272727, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, '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': '1025403', 'n_tokens_mistral': 733, 'n_tokens_neox': 715, 'n_words': 128}