<commit_before>'use strict';

module.exports = function(gulp, $, config, _) {
	var proxyTarget = _.get(config, 'proxy.url', config.consts.proxy.url);
	var proxyPrefixes = _.get(config, 'proxy.prefixes', config.consts.proxy.prefixes);
	var proxy = $.httpProxy.createProxyServer({
		target: proxyTarget
	});

    function isProxiedPrefix(url) {
        return _.some(proxyPrefixes, function (expression) {
            return expression.test(url);
        });
    }

	function proxyMiddleware(req, res, next) {
		if (isProxiedPrefix(req.url)) {
			proxy.web(req, res, function (err) {
                next(err);
            });
		} else {
			next();
		}
	}

    function server(filesToWatch, filesToServe) {
        return $.browserSync({
            files: filesToWatch,
            notify: false,
            server: {
                baseDir: filesToServe,
                middleware: proxyMiddleware
            }
        });
    }

	gulp.task('serve', function () {
        return server([
            config.paths.app.base,
            config.paths.build.tmp.base,
        ], _.union([
            config.paths.build.tmp.base,
            config.paths.base
        ], config.paths.app.base));
	});

    gulp.task('serve:dist', ['build'], function () {
        return server(config.paths.build.dist.base, config.paths.build.dist.base);
    });
};<commit_msg>Set middleware function to be definable<commit_after>'use strict';

module.exports = function(gulp, $, config, _) {
	var proxyTarget = _.get(config, 'proxy.url', config.consts.proxy.url);
	var proxyPrefixes = _.get(config, 'proxy.prefixes', config.consts.proxy.prefixes);
	var proxy = $.httpProxy.createProxyServer({
		target: proxyTarget
	});

    function isProxiedPrefix(url) {
        return _.some(proxyPrefixes, function (expression) {
            return expression.test(url);
        });
    }

	function proxyMiddleware(req, res, next) {
		if (isProxiedPrefix(req.url)) {
			proxy.web(req, res, function (err) {
                next(err);
            });
		} else {
			next();
		}
	}

    function server(filesToWatch, filesToServe) {
        return $.browserSync({
            files: filesToWatch,
            notify: false,
            server: {
                baseDir: filesToServe,
                middleware: config.consts.browserSync.middleware || proxyMiddlewares
            }
        });
    }

	gulp.task('serve', function () {
        return server([
            config.paths.app.base,
            config.paths.build.tmp.base,
        ], _.union([
            config.paths.build.tmp.base,
            config.paths.base
        ], config.paths.app.base));
	});

    gulp.task('serve:dist', ['build'], function () {
        return server(config.paths.build.dist.base, config.paths.build.dist.base);
    });
};
{'fraction_non_alphanumeric': 0.14101184068891282, 'fraction_numerical': 0.0, 'mean_word_length': 2.1790193842645382, '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': '464915', 'n_tokens_mistral': 862, 'n_tokens_neox': 831, 'n_words': 148}