<commit_before>const fs = require('fs');
const buildConstants = require('../buildConstants');

const cleanTask = (resolve, reject) => {
    fs.promises.rmdir(buildConstants.outputDirectory, { recursive: true })
        .then(() => {
            fs.promises.mkdir(buildConstants.outputDirectory)
                .then(resolve)
                .catch((mkdirError) => reject(mkdirError));
        })
        .catch((rmdirError) => reject(rmdirError));
};

module.exports = cleanTask;<commit_msg>Make the clean task continue on if the output folder does not exist.<commit_after>const fs = require('fs');
const buildConstants = require('../buildConstants');

const cleanTask = (resolve, reject) => {
    const recreatedOutputDirectory = (res, rej) => {
        fs.promises.mkdir(buildConstants.outputDirectory)
            .then(res)
            .catch((mkdirError) => rej(mkdirError));
    };

    fs.promises.stat(buildConstants.outputDirectory)
        .then(() => {
            fs.promises.rmdir(buildConstants.outputDirectory, { recursive: true })
                .then(() => recreatedOutputDirectory(resolve, reject))
                .catch((rmdirError) => reject(rmdirError));
        })
        .catch(() => {
            recreatedOutputDirectory(resolve, reject);
        });
};

module.exports = cleanTask;
{'fraction_non_alphanumeric': 0.14569031273836766, 'fraction_numerical': 0.0, 'mean_word_length': 2.802898550724638, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '887869', 'n_tokens_mistral': 363, 'n_tokens_neox': 348, 'n_words': 66}