<commit_before>var gulp = require('gulp');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var evstream = require('event-stream');
var cleanCSS = require('gulp-clean-css');
var nodemon = require('gulp-nodemon');
var path = require('path');

gulp.task('start', function() {
    nodemon({
        script: 'server.js',
        ignore: '*.*'
    });
})

gulp.task('watch', function () {
    nodemon({
        script: 'server.js',
        ext: 'js html css',
        env: {'NODE_ENV': 'dev'},
        watch: [
            'app/',
            'config/'
        ],
        tasks: function (changedFiles) {
            var tasks = [];
            changedFiles.forEach(function (file) {
                if (path.extname(file) === '.js' && !~tasks.indexOf('minjs'))
                    tasks.push('minjs');
                if (path.extname(file) === '.css' && !~tasks.indexOf('mincss'))
                    tasks.push('mincss');
            });
            return tasks;
        }
    }).on('restart?', function () {
        gulp.start('default');
    });
});

gulp.task('default', function () {
    gulp.start('minjs');
    gulp.start('mincss');
});

gulp.task('mincss', function () {
    var files = [
        {
            src: 'app/public/css/form.css',
            name: 'form.min.css'
        },
        {
            src: 'app/public/css/home.css',
            name: 'home.min.css'
        },
        {
            src: 'app/public/css/panel.css',
            name: 'panel.min.css'
        },
        {
            src: 'app/public/css/index.css',
            name: 'index.min.css'
        }
    ];

    var tasks = files.map(function (entry) {
        return gulp.src(entry.src)
            .pipe(cleanCSS())
            .pipe(rename(entry.name))
            .pipe(gulp.dest('public/css'));
    });

    return evstream.merge.apply(null, tasks);
})

gulp.task('minjs', function () {
    gulp.start('concatjs');
    gulp.start('browserify');
});

gulp.task('concatjs', function () {
    var files = [
        {
            src: [
                'app/public/services/*.js',
                'app/public/panel/**/*.js'
            ],
            name: 'panel.min.js'
        },
        {
            src: [
                'app/public/services/*.js',
                'app/public/shimapan/**/*.js'
            ],
            name: 'shimapan.min.js'
        },
        {
            src: 'app/public/index/*.js',
            name: 'index.min.js'
        }
    ];

    var tasks = files.map(function (entry) {
        return gulp.src(entry.src)
            .pipe(concat(entry.name))
            .pipe(uglify().on('error', function(err) {
                console.log(err.toString());
            }))
            .pipe(gulp.dest('public/js'));
    });

    return evstream.merge.apply(null, tasks);
})

gulp.task('browserify', ['concatjs'], function () {
    var files = [
        {
            src: 'public/js/shimapan.min.js',
            name: 'shimapan.bundle.js'
        },
        {
            src: 'public/js/panel.min.js',
            name: 'panel.bundle.js'
        }
    ];

    var tasks = files.map(function (entry) {
        return browserify({entries: [entry.src]})
            .bundle()
            .pipe(source(entry.src))
            .pipe(rename(entry.name))
            .pipe(gulp.dest('public/js'));
    });

    return evstream.merge.apply(null, tasks);
});<commit_msg>Update gulpfile for gulp 4.0.0<commit_after>'use strict';

const gulp = require('gulp');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const source = require('vinyl-source-stream');
const browserify = require('browserify');
const es = require('event-stream');
const cleanCSS = require('gulp-clean-css');
const nodemon = require('gulp-nodemon');
const path = require('path');

gulp.task('start', (done) => {
    nodemon({
        script: 'server.js',
        ignore: '*.*'
    });
    done();
});

gulp.task('watch', (done) => {
    nodemon({
        script: 'server.js',
        ext: 'js html css',
        env: {'NODE_ENV': 'dev'},
        watch: [
            'app/',
            'config/'
        ],
        tasks: function (changedFiles) {
            var tasks = [];
            changedFiles.forEach(function (file) {
                if (path.extname(file) === '.js' && !~tasks.indexOf('MakeJS'))
                    tasks.push('MakeJS');
                if (path.extname(file) === '.css' && !~tasks.indexOf('MakeCSS'))
                    tasks.push('MakeCSS');
            });
            return tasks;
        }
    }).on('restart?', function () {
        gulp.task('default')();
    });
});

gulp.task('MinifyCSS', () => {
    const files = [
        {
            src: 'app/public/css/form.css',
            dest: 'form.min.css'
        },
        {
            src: 'app/public/css/home.css',
            dest: 'home.min.css'
        },
        {
            src: 'app/public/css/panel.css',
            dest: 'panel.min.css'
        },
        {
            src: 'app/public/css/index.css',
            dest: 'index.min.css'
        }
    ];

    const tasks = files.map(file =>
        gulp.src(file.src)
            .pipe(cleanCSS())
            .pipe(rename(file.dest))
            .pipe(gulp.dest('public/css')));

    return es.merge(tasks)
        .pipe(gulp.dest('public/css'));
});

gulp.task('MinifyJS', () => {
    const files = [
        {
            src: [
                'app/public/services/*.js',
                'app/public/panel/**/*.js'
            ],
            dest: 'panel.min.js'
        },
        {
            src: [
                'app/public/services/*.js',
                'app/public/shimapan/**/*.js'
            ],
            dest: 'shimapan.min.js'
        },
        {
            src: 'app/public/index/*.js',
            dest: 'index.min.js'
        }
    ];

    const tasks = files.map(file =>
        gulp.src(file.src)
            .pipe(concat(file.dest))
            .pipe(uglify())
    );

    return es.merge(tasks)
        .pipe(gulp.dest('public/js'));
});

gulp.task('BrowserifyJS', () => {
    const files = [
        {
            src: 'public/js/shimapan.min.js',
            dest: 'shimapan.bundle.js'
        }, {
            src: 'public/js/panel.min.js',
            dest: 'panel.bundle.js'
        }
    ];

    const tasks = files.map(entry =>
        browserify({entries: [entry.src], debug: true}).bundle()
            .pipe(source(entry.dest))
    );

    return es.merge(tasks)
        .pipe(gulp.dest('public/js'));
});

gulp.task('MakeJS', gulp.series('MinifyJS', 'BrowserifyJS'));
gulp.task('MakeCSS', gulp.series('MinifyCSS'));

gulp.task('default', gulp.parallel('MakeJS', 'MakeCSS'));
{'fraction_non_alphanumeric': 0.1842680262199563, 'fraction_numerical': 0.00043699927166788056, 'mean_word_length': 1.6296438146304097, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4456789', 'n_tokens_mistral': 2199, 'n_tokens_neox': 2166, 'n_words': 337}