<commit_before>var globalFs = require('fs');
var path = require('path');
var parallel = require('continuable-para');
var series = require('continuable-series');
var globalMkdirp = require('mkdirp');
var format = require('util').format;

function createFixtures(dirname, fixtures, opts, callback) {
    if (typeof opts === 'function') {
        callback = opts;
        opts = {};
    }

    var fs = opts.fs || globalFs;
    var mkdirp = opts.mkdirp || globalMkdirp;
    var tasks = Object.keys(fixtures).map(function (key) {
        var value = fixtures[key];
        var loc = path.join(dirname, key);

        if (typeof value === 'string') {
            return fs.writeFile.bind(fs, loc, value);
        } else if (typeof value === 'object') {
            return series([
                fs.mkdir.bind(fs, loc),
                createFixtures.bind(null, loc, value, opts)
            ]);
        } else {
            console.log('throwing lol');
            var msg = format('value not supported %j', value);
            throw new Error(msg);
        }
    });

    tasks.unshift(mkdirp.bind(null, dirname));

    parallel(tasks, callback);
}

module.exports = createFixtures;
<commit_msg>remove comment<commit_after>var globalFs = require('fs');
var path = require('path');
var parallel = require('continuable-para');
var series = require('continuable-series');
var globalMkdirp = require('mkdirp');
var format = require('util').format;

function createFixtures(dirname, fixtures, opts, callback) {
    if (typeof opts === 'function') {
        callback = opts;
        opts = {};
    }

    var fs = opts.fs || globalFs;
    var mkdirp = opts.mkdirp || globalMkdirp;
    var tasks = Object.keys(fixtures).map(function (key) {
        var value = fixtures[key];
        var loc = path.join(dirname, key);

        if (typeof value === 'string') {
            return fs.writeFile.bind(fs, loc, value);
        } else if (typeof value === 'object') {
            return series([
                fs.mkdir.bind(fs, loc),
                createFixtures.bind(null, loc, value, opts)
            ]);
        } else {
            var msg = format('value not supported %j', value);
            throw new Error(msg);
        }
    });

    tasks.unshift(mkdirp.bind(null, dirname));

    parallel(tasks, callback);
}

module.exports = createFixtures;

{'fraction_non_alphanumeric': 0.14407502131287298, 'fraction_numerical': 0.0, 'mean_word_length': 2.456553755522828, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7013400', 'n_tokens_mistral': 698, 'n_tokens_neox': 669, 'n_words': 177}