<commit_before>import concatFiles, { developmentConcatFilesArgs } from './tasks/concats.js';
import compileScripts, { developmentScriptsArgs } from './tasks/scripts.js';
import compileStyles, { developmentStylesArgs } from './tasks/styles.js' ;
import compileSVGs, { developmentSVGsArgs } from './tasks/svgs.js';
import loconfig, { merge } from './utils/config.js';
import message from './utils/message.js';
import notification from './utils/notification.js';
import resolve from './utils/template.js';
import browserSync from 'browser-sync';
import { join } from 'node:path';

// Match a URL protocol.
const regexUrlStartsWithProtocol = /^[a-z0-9\-]:\/\//i;

// Build scripts, compile styles, concat files,
// and generate spritesheets on first hit
concatFiles(...developmentConcatFilesArgs);
compileScripts(...developmentScriptsArgs);
compileStyles(...developmentStylesArgs);
compileSVGs(...developmentSVGsArgs);

// Create a new BrowserSync instance
const server = browserSync.create();

// Start the BrowserSync server
server.init(createServerOptions(loconfig), (err) => {
    if (err) {
        message('Error starting development server', 'error');
        message(err);

        notification({
            title:   'Development server failed',
            message: `${err.name}: ${err.message}`
        });
    }
});

configureServer(server, loconfig);

/**
 * Configures the BrowserSync options.
 *
 * @param  {BrowserSync} server         - The BrowserSync API.
 * @param  {object}      loconfig       - The project configset.
 * @param  {object}      loconfig.paths - The paths options.
 * @param  {object}      loconfig.tasks - The tasks options.
 * @return {void}
 */
function configureServer(server, { paths, tasks }) {
    const views = createViewsArray(paths.views);

    // Reload on any changes to views or processed files
    server.watch(
        [
            ...views,
            join(paths.scripts.dest, '*.js'),
            join(paths.styles.dest, '*.css'),
            join(paths.svgs.dest, '*.svg'),
        ]
    ).on('change', server.reload);

    // Watch source scripts
    server.watch(
        [
            join(paths.scripts.src, '**/*.js'),
        ]
    ).on('change', () => {
        compileScripts(...developmentScriptsArgs);
    });

    // Watch source concats
    server.watch(
        resolve(
            tasks.concats.reduce(
                (patterns, { includes }) => patterns.concat(includes),
                []
            )
        )
    ).on('change', () => {
        concatFiles(...developmentConcatFilesArgs);
    });

    // Watch source styles
    server.watch(
        [
            join(paths.styles.src, '**/*.scss'),
        ]
    ).on('change', () => {
        compileStyles(...developmentStylesArgs);
    });

    // Watch source SVGs
    server.watch(
        [
            join(paths.svgs.src, '*.svg'),
        ]
    ).on('change', () => {
        compileSVGs(...developmentSVGsArgs);
    });
}

/**
 * Creates a new object with all the BrowserSync options.
 *
 * @param  {object} loconfig        - The project configset.
 * @param  {object} loconfig.paths  - The paths options.
 * @param  {object} loconfig.server - The server options.
 * @return {object} Returns the server options.
 */
function createServerOptions({
    paths,
    server: options
}) {
    const config = {
        open: false,
        notify: false
    };

    // Resolve the URL for the BrowserSync server
    if (isNonEmptyString(paths.url)) {
        // Use proxy
        config.proxy = paths.url;
    } else if (isNonEmptyString(paths.dest)) {
        // Use base directory
        config.server = {
            baseDir: paths.dest
        };
    }
<commit_msg>Disable browsersync ghostMode<commit_after>import concatFiles, { developmentConcatFilesArgs } from './tasks/concats.js';
import compileScripts, { developmentScriptsArgs } from './tasks/scripts.js';
import compileStyles, { developmentStylesArgs } from './tasks/styles.js' ;
import compileSVGs, { developmentSVGsArgs } from './tasks/svgs.js';
import loconfig, { merge } from './utils/config.js';
import message from './utils/message.js';
import notification from './utils/notification.js';
import resolve from './utils/template.js';
import browserSync from 'browser-sync';
import { join } from 'node:path';

// Match a URL protocol.
const regexUrlStartsWithProtocol = /^[a-z0-9\-]:\/\//i;

// Build scripts, compile styles, concat files,
// and generate spritesheets on first hit
concatFiles(...developmentConcatFilesArgs);
compileScripts(...developmentScriptsArgs);
compileStyles(...developmentStylesArgs);
compileSVGs(...developmentSVGsArgs);

// Create a new BrowserSync instance
const server = browserSync.create();

// Start the BrowserSync server
server.init(createServerOptions(loconfig), (err) => {
    if (err) {
        message('Error starting development server', 'error');
        message(err);

        notification({
            title:   'Development server failed',
            message: `${err.name}: ${err.message}`
        });
    }
});

configureServer(server, loconfig);

/**
 * Configures the BrowserSync options.
 *
 * @param  {BrowserSync} server         - The BrowserSync API.
 * @param  {object}      loconfig       - The project configset.
 * @param  {object}      loconfig.paths - The paths options.
 * @param  {object}      loconfig.tasks - The tasks options.
 * @return {void}
 */
function configureServer(server, { paths, tasks }) {
    const views = createViewsArray(paths.views);

    // Reload on any changes to views or processed files
    server.watch(
        [
            ...views,
            join(paths.scripts.dest, '*.js'),
            join(paths.styles.dest, '*.css'),
            join(paths.svgs.dest, '*.svg'),
        ]
    ).on('change', server.reload);

    // Watch source scripts
    server.watch(
        [
            join(paths.scripts.src, '**/*.js'),
        ]
    ).on('change', () => {
        compileScripts(...developmentScriptsArgs);
    });

    // Watch source concats
    server.watch(
        resolve(
            tasks.concats.reduce(
                (patterns, { includes }) => patterns.concat(includes),
                []
            )
        )
    ).on('change', () => {
        concatFiles(...developmentConcatFilesArgs);
    });

    // Watch source styles
    server.watch(
        [
            join(paths.styles.src, '**/*.scss'),
        ]
    ).on('change', () => {
        compileStyles(...developmentStylesArgs);
    });

    // Watch source SVGs
    server.watch(
        [
            join(paths.svgs.src, '*.svg'),
        ]
    ).on('change', () => {
        compileSVGs(...developmentSVGsArgs);
    });
}

/**
 * Creates a new object with all the BrowserSync options.
 *
 * @param  {object} loconfig        - The project configset.
 * @param  {object} loconfig.paths  - The paths options.
 * @param  {object} loconfig.server - The server options.
 * @return {object} Returns the server options.
 */
function createServerOptions({
    paths,
    server: options
}) {
    const config = {
        open: false,
        notify: false,
        ghostMode: false
    };

    // Resolve the URL for the BrowserSync server
    if (isNonEmptyString(paths.url)) {
        // Use proxy
        config.proxy = paths.url;
    } else if (isNonEmptyString(paths.dest)) {
        // Use base directory
        config.server = {
            baseDir: paths.dest
        };
    }

{'fraction_non_alphanumeric': 0.14301075268817204, 'fraction_numerical': 0.0005376344086021505, 'mean_word_length': 2.359367945823928, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4351247', 'n_tokens_mistral': 2173, 'n_tokens_neox': 2116, 'n_words': 518}