<commit_before>"use strict";

var config = require('../../../../core/config'),
    runCreateBundle = require("../../../../core/bundle/runCreateBundle.js"),
    paths = config.paths,
    fs = require('fs');

var init;

function serveInitPage(req, res, next) {

    var initPagePath = paths.bundle + '/index.html';

    function serve() {
        fs.readFile(initPagePath, function onFileRead(err, data) {
            if(err) {
                throw new Error("(alamid) No index.html file defined at '" + initPagePath + "'");
            }
            res.setHeader('Content-Type', 'text/html; charset=utf-8');
            res.end(data);
        });
    }

    if (config.isDev && config.useBundling === true) {
        //update bundle
        runCreateBundle(config, function(err) {
            if(err) {
                next("(alamid) Error with bundle-creation: " + err.message);
                return;
            }
           serve();
        });
    }
    else {
        serve();
    }
}

module.exports = serveInitPage;<commit_msg>- disabled reBundling for file-requests on root-path<commit_after>"use strict";

var config = require('../../../../core/config'),
    runCreateBundle = require("../../../../core/bundle/runCreateBundle.js"),
    paths = config.paths,
    fs = require('fs');

var init;

function serveInitPage(req, res, next) {

    var initPagePath = paths.bundle + '/index.html';

    function serve() {
        fs.readFile(initPagePath, function onFileRead(err, data) {
            if(err) {
                throw new Error("(alamid) No index.html file defined at '" + initPagePath + "'");
            }
            res.setHeader('Content-Type', 'text/html; charset=utf-8');
            res.end(data);
        });
    }

    //only in DEV with bundling activated
    //additionally check for "." to filter file-requests (favicon, 2.app.js)
    if (config.isDev && config.useBundling === true && (req.parsedURL.pathname).indexOf(".") === -1) {
        //update bundle
        runCreateBundle(config, function(err) {
            if(err) {
                next("(alamid) Error with bundle-creation: " + err.message);
                return;
            }
           serve();
        });
    }
    else {
        serve();
    }
}

module.exports = serveInitPage;
{'fraction_non_alphanumeric': 0.16140350877192983, 'fraction_numerical': 0.0017543859649122807, 'mean_word_length': 1.9394329896907216, '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': '672297', 'n_tokens_mistral': 681, 'n_tokens_neox': 655, 'n_words': 143}