<commit_before>'use strict';

import * as fse from 'fs-extra';
import * as path from 'path';
import * as pify from 'pify';
import * as rimraf from 'rimraf';

export module CacheStorage {
    const _baseDir = path.join(__dirname, "..", "..", "cache");

    /** Get full path of cache file */
    export function getFullPath(filename: string): string {
        return path.join(_baseDir, filename);
    }

    /** Clear all files */
    export function clear(): Promise<void> {
        return pify(rimraf)(_baseDir);
    }

    /** writeFile */
    export function writeFile(filename: string, data: any): Promise<void> {
        return pify(fse.ensureDir)(_baseDir).then(() => {
            return pify(fse.writeFile)(getFullPath(filename), data);
        });
    }

    /** readFile */
    export function readFile(filename: string, encoding: string = null): Promise<string|Buffer> {
        return pify(fse.readFile)(getFullPath(filename), encoding);
    }

    /** Check file existence */
    export function exists(filename: string): Promise<boolean> {
        return pify(fse.exists)(getFullPath(filename));
    }

    /** Remove file */
    export function unlink(filename: string): Promise<void> {
        return pify(fse.unlink)(getFullPath(filename));
    }

    /** Watch file */
    export function watch(filename, options, listener): fse.FSWatcher {
        return fse.watch(getFullPath(filename), options, listener);
    }
}
<commit_msg>Fix ensureDir rule<commit_after>'use strict';

import * as fse from 'fs-extra';
import * as path from 'path';
import * as pify from 'pify';
import * as rimraf from 'rimraf';

export module CacheStorage {
    const _baseDir = path.join(__dirname, "..", "..", "cache");

    /** Get full path of cache file */
    export function getFullPath(filename: string): string {
        return path.join(_baseDir, filename);
    }

    /** Clear all files */
    export function clear(): Promise<void> {
        return pify(rimraf)(_baseDir);
    }

    /** writeFile */
    export function writeFile(filename: string, data: any): Promise<void> {
        let fullPath = getFullPath(filename);
        return pify(fse.ensureDir)(path.dirname(fullPath)).then(() => {
            return pify(fse.writeFile)(fullPath, data);
        });
    }

    /** readFile */
    export function readFile(filename: string, encoding: string = null): Promise<string|Buffer> {
        return pify(fse.readFile)(getFullPath(filename), encoding);
    }

    /** Check file existence */
    export function exists(filename: string): Promise<boolean> {
        return pify(fse.exists)(getFullPath(filename));
    }

    /** Remove file */
    export function unlink(filename: string): Promise<void> {
        return pify(fse.unlink)(getFullPath(filename));
    }

    /** Watch file */
    export function watch(filename, options, listener): fse.FSWatcher {
        return fse.watch(getFullPath(filename), options, listener);
    }
}

{'fraction_non_alphanumeric': 0.14009497964721845, 'fraction_numerical': 0.0, 'mean_word_length': 3.1072423398328692, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '2182484', 'n_tokens_mistral': 862, 'n_tokens_neox': 843, 'n_words': 221}