<commit_before>import browserSync from 'browser-sync';
import path        from 'path';

import buildFile from './build-file';

export default function server(file, error) {
    let bs = browserSync.create();

    bs.watch(file).on('change', () => {
        buildFile(file).then(bs.reload).catch(error.bind(this, false));
    });

    buildFile(file).then( (output) => {
        bs.init({
            logPrefix: 'showbox',
            ghostMode: false,
            startPath: '/' + path.basename(output),
            server:    path.dirname(output),
            notify:    false
        });
    }).catch(error.bind(this, true));
}<commit_msg>Safer server<commit_after>import browserSync from 'browser-sync';
import path        from 'path';

import buildFile from './build-file';

export default function server(file, error) {
    let bs = browserSync.create();

    bs.watch(file).on('change', () => {
        setTimeout( () => {
            buildFile(file).then(bs.reload).catch(error.bind(this, false));
        }, 1);
    });

    buildFile(file).then( (output) => {
        bs.init({
            logPrefix: 'showbox',
            ghostMode: false,
            startPath: '/' + path.basename(output),
            server:    path.dirname(output),
            notify:    false
        });
    }).catch(error.bind(this, true));
}
{'fraction_non_alphanumeric': 0.16114457831325302, 'fraction_numerical': 0.0007530120481927711, 'mean_word_length': 2.2896039603960396, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '6133482', 'n_tokens_mistral': 396, 'n_tokens_neox': 386, 'n_words': 79}