<commit_before>"use strict";

var connect      = require("connect");
var serverUtils  = require("./utils.js");
var resolve      = require("path").resolve;
var utils        = require("../utils.js");
var serveStatic  = require("serve-static");
var serveIndex   = require("serve-index");

/**
 * @param {BrowserSync} bs
 * @param scripts
 * @returns {*}
 */
module.exports = function createServer (bs, scripts) {

    var options            = bs.options;
    var server             = options.get("server");
    var basedirs           = utils.arrayify(server.get("baseDir"));
    var serveStaticOptions = server.get("serveStaticOptions").toJS(); // passed to 3rd party

    var _serveStatic = 0;
    var _routes = 0;
    var middlewareAdded = bs.options
        /**
         * Add directory Middleware if given in server.directory
         */
        .update("middleware", function (mw) {
            if (!server.has("directory")) {
                return mw;
            }

            return mw.concat({
                route: "",
                handle: serveIndex(resolve(basedirs[0]), {icons:true}),
                id: "Browsersync Server Directory Middleware"<commit_msg>support falsey values for directory setting<commit_after>"use strict";

var connect      = require("connect");
var serverUtils  = require("./utils.js");
var resolve      = require("path").resolve;
var utils        = require("../utils.js");
var serveStatic  = require("serve-static");
var serveIndex   = require("serve-index");

/**
 * @param {BrowserSync} bs
 * @param scripts
 * @returns {*}
 */
module.exports = function createServer (bs, scripts) {

    var options            = bs.options;
    var server             = options.get("server");
    var basedirs           = utils.arrayify(server.get("baseDir"));
    var serveStaticOptions = server.get("serveStaticOptions").toJS(); // passed to 3rd party

    var _serveStatic = 0;
    var _routes = 0;
    var middlewareAdded = bs.options
        /**
         * Add directory Middleware if given in server.directory
         */
        .update("middleware", function (mw) {
            if (!server.get("directory")) {
                return mw;
            }

            return mw.concat({
                route: "",
                handle: serveIndex(resolve(basedirs[0]), {icons:true}),
                id: "Browsersync Server Directory Middleware"
{'fraction_non_alphanumeric': 0.1345668629100084, 'fraction_numerical': 0.00336417157275021, 'mean_word_length': 2.258904109589041, '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': '3800030', 'n_tokens_mistral': 657, 'n_tokens_neox': 632, 'n_words': 166}