<commit_before>'use strict';

import gulp from 'gulp';
import babel from 'gulp-babel';
import sass from 'gulp-sass';
import autoprefixer from 'gulp-autoprefixer';
import sourcemaps from 'gulp-sourcemaps';
import concat from 'gulp-concat';
import cleanCSS from 'gulp-clean-css';
import plumber from 'gulp-plumber';
import uglify from 'gulp-uglify';
import refresh from 'gulp-refresh';
import htmlmin from 'gulp-htmlmin';
import clean from 'gulp-clean';
import inject from 'gulp-inject';
import es from 'event-stream';

const dir = {
    src: 'src',
    dest: './dist'
};

gulp.task('styles', done => {
    gulp.src(`${dir.src}/styles/**/*.scss`)
        .pipe(plumber(error => {
            console.log(error.toString());
            this.emit('end');
        }))
        .pipe(sourcemaps.init())
        .pipe(sass().on('error', sass.logError))
        .pipe(autoprefixer())
        .pipe(concat('main.css'))
        .pipe(cleanCSS())
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(dir.dest))
        .pipe(refresh());

    done();
});

const vendorStream = gulp.src('./static/**/*.js')
    .pipe(plumber(error => {
        console.log(error.toString());
        this.emit('end');
    }))
    .pipe(concat('vendor.js'))
    .pipe(gulp.dest(dir.dest));

const appStream = gulp.src(`${dir.src}/scripts/**/*.js`)
    .pipe(plumber(error => {
        console.log(error.toString());
        this.emit('end');
    }))
    .pipe(sourcemaps.init())
    .pipe(babel({
        presets: ['@babel/env']
    }))
    .pipe(concat('index.js'))
    .pipe(uglify())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(dir.dest));

gulp.task('vendor', done => {
    gulp.src('./static/**/*.js')
        .pipe(plumber(error => {
            console.log(error.toString());
            this.emit('end');
        }))
        .pipe(concat('vendor.js'))
        .pipe(gulp.dest(dir.dest));

    done();
});

gulp.task('scripts', gulp.series('vendor'), () => {
    return gulp.src(`${dir.src}/scripts/**/*.js`)
        .pipe(plumber(error => {
            console.log(error.toString());
            this.emit('end');
        }))
        .pipe(sourcemaps.init())
        .pipe(babel({
            presets: ['@babel/env']
        }))
        .pipe(concat('index.js'))
        .pipe(uglify())
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(dir.dest));
});

gulp.task('minify', () => {
    return gulp.src(`${dir.src}/*.html`)
        .pipe(plumber(error => {
            console.log(error.toString());
            this.emit('end');
        }))
        .pipe(htmlmin({
            collapseWhitespace: true
        }))
        .pipe(inject(es.merge(vendorStream, appStream), {
            removeTags: true
        }))
        .pipe(gulp.dest('./'));
});

gulp.task('clean', () => {
    return gulp.src(dir.dest, { read: false })
        .pipe(plumber(error => {
            console.log(error.toString());
            this.emit('end');
        }))
        .pipe(clean());
});

gulp.task('default', gulp.series('clean', 'styles', 'minify'));

gulp.task('watch', () => {
    refresh.listen();
    gulp.watch(`${dir.src}/styles/**/*.scss`, gulp.series('styles')).on('change', e => {
        console.log('\t   File ' + e.type + '...');
    });
    gulp.watch(`${dir.src}/scripts/**/*.js`, gulp.series('scripts')).on('change', e => {
        console.log('\t   File ' + e.type + '...');
    });
    gulp.watch(`${dir.src}/*.html`, gulp.series('minify')).on('change', e => {
        console.log('\t   File ' + e.type + '...');
    });
});<commit_msg>allowEmpty on gulp clean<commit_after>'use strict';

import gulp from 'gulp';
import babel from 'gulp-babel';
import sass from 'gulp-sass';
import autoprefixer from 'gulp-autoprefixer';
import sourcemaps from 'gulp-sourcemaps';
import concat from 'gulp-concat';
import cleanCSS from 'gulp-clean-css';
import plumber from 'gulp-plumber';
import uglify from 'gulp-uglify';
import refresh from 'gulp-refresh';
import htmlmin from 'gulp-htmlmin';
import clean from 'gulp-clean';
import inject from 'gulp-inject';
import es from 'event-stream';

const dir = {
    src: 'src',
    dest: './dist'
};

gulp.task('styles', done => {
    gulp.src(`${dir.src}/styles/**/*.scss`)
        .pipe(plumber(error => {
            console.log(error.toString());
            this.emit('end');
        }))
        .pipe(sourcemaps.init())
        .pipe(sass().on('error', sass.logError))
        .pipe(autoprefixer())
        .pipe(concat('main.css'))
        .pipe(cleanCSS())
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(dir.dest))
        .pipe(refresh());

    done();
});

const vendorStream = gulp.src('./static/**/*.js')
    .pipe(plumber(error => {
        console.log(error.toString());
        this.emit('end');
    }))
    .pipe(concat('vendor.js'))
    .pipe(gulp.dest(dir.dest));

const appStream = gulp.src(`${dir.src}/scripts/**/*.js`)
    .pipe(plumber(error => {
        console.log(error.toString());
        this.emit('end');
    }))
    .pipe(sourcemaps.init())
    .pipe(babel({
        presets: ['@babel/env']
    }))
    .pipe(concat('index.js'))
    .pipe(uglify())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(dir.dest));

gulp.task('vendor', done => {
    gulp.src('./static/**/*.js')
        .pipe(plumber(error => {
            console.log(error.toString());
            this.emit('end');
        }))
        .pipe(concat('vendor.js'))
        .pipe(gulp.dest(dir.dest));

    done();
});

gulp.task('scripts', gulp.series('vendor'), () => {
    return gulp.src(`${dir.src}/scripts/**/*.js`)
        .pipe(plumber(error => {
            console.log(error.toString());
            this.emit('end');
        }))
        .pipe(sourcemaps.init())
        .pipe(babel({
            presets: ['@babel/env']
        }))
        .pipe(concat('index.js'))
        .pipe(uglify())
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(dir.dest));
});

gulp.task('minify', () => {
    return gulp.src(`${dir.src}/*.html`)
        .pipe(plumber(error => {
            console.log(error.toString());
            this.emit('end');
        }))
        .pipe(htmlmin({
            collapseWhitespace: true
        }))
        .pipe(inject(es.merge(vendorStream, appStream), {
            removeTags: true
        }))
        .pipe(gulp.dest('./'));
});

gulp.task('clean', () => {
    return gulp.src(dir.dest, { read: false, allowEmpty: true })
        .pipe(plumber(error => {
            console.log(error.toString());
            this.emit('end');
        }))
        .pipe(clean());
});

gulp.task('default', gulp.series('clean', 'styles', 'minify'));

gulp.task('watch', () => {
    refresh.listen();
    gulp.watch(`${dir.src}/styles/**/*.scss`, gulp.series('styles')).on('change', e => {
        console.log('\t   File ' + e.type + '...');
    });
    gulp.watch(`${dir.src}/scripts/**/*.js`, gulp.series('scripts')).on('change', e => {
        console.log('\t   File ' + e.type + '...');
    });
    gulp.watch(`${dir.src}/*.html`, gulp.series('minify')).on('change', e => {
        console.log('\t   File ' + e.type + '...');
    });
});
{'fraction_non_alphanumeric': 0.22556602446913232, 'fraction_numerical': 0.0, 'mean_word_length': 2.3547169811320754, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, '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': '63703', 'n_tokens_mistral': 2425, 'n_tokens_neox': 2406, 'n_words': 351}