<commit_before>var _ = require('underscore'),
    fs = require('fs'),
    Path = require('path'),
    passError = require('passerror'),
    constants = process.ENOENT ? process : require('constants'),
    mkdirp = require('mkdirp'),
    seq = require('seq'),
    urlTools = require('urltools');

mkpathAndWriteFile = function mkpathAndWriteFile(fileName, contents, encoding, cb) {
    fs.writeFile(fileName, contents, encoding, function (err) {
        if (err && (err.code === 'ENOENT' || err.errno === constants.ENOENT)) {
            mkdirp(Path.dirname(fileName), passError(cb, function () {
                fs.writeFile(fileName, contents, encoding, cb);
            }));
        } else {
            cb(err);
        }
    });
};

module.exports = function (queryObj, outRoot, root) {
    if (outRoot.indexOf('file://') === -1) {
        outRoot = urlTools.fsDirToFileUrl(outRoot);
    }

    return function writeAssetsToDisc(assetGraph, cb) {<commit_msg>transforms/writeAssetsToDisc: Guard against missing outRoot<commit_after>var _ = require('underscore'),
    fs = require('fs'),
    Path = require('path'),
    passError = require('passerror'),
    constants = process.ENOENT ? process : require('constants'),
    mkdirp = require('mkdirp'),
    seq = require('seq'),
    urlTools = require('urltools');

mkpathAndWriteFile = function mkpathAndWriteFile(fileName, contents, encoding, cb) {
    fs.writeFile(fileName, contents, encoding, function (err) {
        if (err && (err.code === 'ENOENT' || err.errno === constants.ENOENT)) {
            mkdirp(Path.dirname(fileName), passError(cb, function () {
                fs.writeFile(fileName, contents, encoding, cb);
            }));
        } else {
            cb(err);
        }
    });
};

module.exports = function (queryObj, outRoot, root) {
    if (outRoot && outRoot.indexOf('file://') === -1) {
        outRoot = urlTools.fsDirToFileUrl(outRoot);
    }

    return function writeAssetsToDisc(assetGraph, cb) {
{'fraction_non_alphanumeric': 0.15648662291771834, 'fraction_numerical': 0.0010095911155981827, 'mean_word_length': 3.078189300411523, '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': '4607813', 'n_tokens_mistral': 592, 'n_tokens_neox': 588, 'n_words': 121}