<commit_before>'use strict';

var _ = require('lodash-node'),
    es = require('event-stream'),
    PluginError = require('gulp-util').PluginError,
    Cache = require('cache-swap'),
    TaskProxy = require('./lib/TaskProxy');

var fileCache = new Cache({
    cacheDirName: 'gulp-cache'
});

var defaultOptions = {
    fileCache: fileCache,
    key: _.noop,
    success: _.noop,
    value: _.noop
};

var cacheTask = {
    proxy: function (name, opts) {
        // Check if name was not passed, use default
        if (_.isObject(name)) {
            opts = name;
            name = 'default';
        }

        var self = this;

        // Make sure we have some sane defaults
        opts = _.defaults(opts || {}, defaultOptions);
        
        // Check for required task option
        if (!opts.task) {
            throw new PluginError('gulp-cache', 'Must pass a task to ' + name + ' cache.proxy');
        }

        // Pass through the file and cb to _processFile along with the opts
        return es.map(function (file, cb) {
            var taskProxy = new TaskProxy({
                name: name,
                file: file,
                opts: opts
            });

            taskProxy.processFile().then(function (result) {
                cb(null, result);
            }).catch(function (err) {
                cb(new PluginError('gulp-cache', 'Error proxying task ' + self.name + ': ' + err.message));
            });
        });
    }
};

cacheTask.fileCache = fileCache;

module.exports = cacheTask;<commit_msg>Fix error to pass through<commit_after>'use strict';

var _ = require('lodash-node'),
    es = require('event-stream'),
    PluginError = require('gulp-util').PluginError,
    Cache = require('cache-swap'),
    TaskProxy = require('./lib/TaskProxy');

var fileCache = new Cache({
    cacheDirName: 'gulp-cache'
});

var defaultOptions = {
    fileCache: fileCache,
    key: _.noop,
    success: _.noop,
    value: _.noop
};

var cacheTask = {
    proxy: function (name, opts) {
        // Check if name was not passed, use default
        if (_.isObject(name)) {
            opts = name;
            name = 'default';
        }

        var self = this;

        // Make sure we have some sane defaults
        opts = _.defaults(opts || {}, defaultOptions);
        
        // Check for required task option
        if (!opts.task) {
            throw new PluginError('gulp-cache', 'Must pass a task to ' + name + ' cache.proxy');
        }

        // Pass through the file and cb to _processFile along with the opts
        return es.map(function (file, cb) {
            var taskProxy = new TaskProxy({
                name: name,
                file: file,
                opts: opts
            });

            taskProxy.processFile().then(function (result) {
                cb(null, result);
            }).catch(function (err) {
                cb(new PluginError('gulp-cache', err));
            });
        });
    }
};

cacheTask.fileCache = fileCache;

module.exports = cacheTask;
{'fraction_non_alphanumeric': 0.12805280528052806, 'fraction_numerical': 0.0, 'mean_word_length': 1.8353601496725913, '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': '1574986', 'n_tokens_mistral': 869, 'n_tokens_neox': 831, 'n_words': 241}