<commit_before>var gulp = require('gulp');
var fs = require('fs');
var connect = require('gulp-connect');
var runSequence = require('run-sequence');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var less = require('gulp-less');
var sass = require('gulp-sass');
var cleancss = require('gulp-clean-css');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var svgstore = require('gulp-svgstore');
var svgmin = require('gulp-svgmin');
var cheerio = require('gulp-cheerio');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var livereload = require('gulp-livereload');
var config = require('js-yaml').safeLoad(fs.readFileSync('rockety.yml', 'utf8'));
var sources = [];
var production = false;
var serving = false;

gulp.task('config', function () {
    console.log(JSON.stringify(config, null, 4));
});

function css(src) {
    var stream, vendors = [], isLess;

    if (!src.css) {
        return;
    }

    /**
     * Vendor files
     */
    (src.css.vendor || []).forEach(function (item) {
        vendors.push(item);
    });
    if (vendors.length) {
        gulp.src(vendors)
            .pipe(cleancss())
            .pipe(concat('vendor.css'))
            .pipe(gulp.dest(src.dest + '/css'));
    }

    /**
     * Own styles
     */
    if (!src.css.styles.less && !src.css.styles.sass) {
        return;
    }

    isLess = src.css.styles.less ? true : false;

    stream = isLess ?
        gulp.src(src.css.styles.less ? src.src + '/less/' + src.css.styles.less : []) :
        gulp.src(src.css.styles.sass ? src.src + '/sass/' + src.css.styles.sass : []);

    if (src.css.sourcemap && !production) {
        stream = stream.pipe(sourcemaps.init());
    }

    stream = stream.pipe(isLess ? less() : sass());

    stream = stream.pipe(autoprefixer(src.css.autoprefixer || {
        browsers: ['last 2 versions'],
    }));

    if (src.css.minify || production) {
        stream = stream.pipe(cleancss());
    }

    stream = stream.pipe(concat('style.css'));

    if (src.css.sourcemap && !production) {
        stream = stream.pipe(sourcemaps.write(src.css.sourcemapLocation || null));
    }

    stream = stream.pipe(gulp.dest(src.dest + '/css'));
    stream.pipe(serving ? connect.reload() : livereload());
}

function svg(src) {
    var inline = src.svg.inline || false;
    return gulp.src(src.src + '/svg/*.svg')
        .pipe(rename({prefix: 'shape-'}))
        .pipe(svgmin())
        .pipe(svgstore({
            inlineSvg: inline
        }))
        .pipe(cheerio({
            run: function ($) {
                if (!inline) {
                    $('svg').attr('style', 'display:none');
                }
            },
            parserOptions: {xmlMode: true}
        }))
        .pipe(rename('shapes.svg'))
        .pipe(gulp.dest(src.dest + '/svg'))
        .pipe(serving ? connect.reload() : livereload());
}

function js(src) {
    var stream, vendors = [], scripts = [], stream;

    if (!src.js) {
        return;
    }

    /**
     * Vendor files
     */
    (src.js.vendor || []).forEach(function (item) {
        vendors.push(item);
    });
    if (vendors) {
        gulp.src(vendors)
            .pipe(uglify().on('error', function(err){
                console.log(err);
            }))
            .pipe(concat('vendor.js'))
            .pipe(gulp.dest(src.dest + '/js'));
    }

    /**
     * Own code
     */
    (src.js.scripts || []).forEach(function (item) {
        scripts.push(src.src + '/js/' + item);
    });

    if (!scripts.length) {
        return;
    }
<commit_msg>Handled error when syntax of less/sass is wrong and crashes the watch process<commit_after>var gulp = require('gulp');
var fs = require('fs');
var connect = require('gulp-connect');
var runSequence = require('run-sequence');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var less = require('gulp-less');
var sass = require('gulp-sass');
var cleancss = require('gulp-clean-css');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var svgstore = require('gulp-svgstore');
var svgmin = require('gulp-svgmin');
var cheerio = require('gulp-cheerio');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var livereload = require('gulp-livereload');
var config = require('js-yaml').safeLoad(fs.readFileSync('rockety.yml', 'utf8'));
var sources = [];
var production = false;
var serving = false;

gulp.task('config', function () {
    console.log(JSON.stringify(config, null, 4));
});

function css(src) {
    var stream, vendors = [], isLess;

    if (!src.css) {
        return;
    }

    /**
     * Vendor files
     */
    (src.css.vendor || []).forEach(function (item) {
        vendors.push(item);
    });
    if (vendors.length) {
        gulp.src(vendors)
            .pipe(cleancss())
            .pipe(concat('vendor.css'))
            .pipe(gulp.dest(src.dest + '/css'));
    }

    /**
     * Own styles
     */
    if (!src.css.styles.less && !src.css.styles.sass) {
        return;
    }

    isLess = src.css.styles.less ? true : false;

    stream = isLess ?
        gulp.src(src.css.styles.less ? src.src + '/less/' + src.css.styles.less : []) :
        gulp.src(src.css.styles.sass ? src.src + '/sass/' + src.css.styles.sass : []);

    if (src.css.sourcemap && !production) {
        stream = stream.pipe(sourcemaps.init());
    }

    stream = stream.pipe(isLess ? less() : sass());
    stream.on('error', function(err) {
        console.log(err.message);
    });

    stream = stream.pipe(autoprefixer(src.css.autoprefixer || {
        browsers: ['last 2 versions'],
    }));

    if (src.css.minify || production) {
        stream = stream.pipe(cleancss());
    }

    stream = stream.pipe(concat('style.css'));

    if (src.css.sourcemap && !production) {
        stream = stream.pipe(sourcemaps.write(src.css.sourcemapLocation || null));
    }

    stream = stream.pipe(gulp.dest(src.dest + '/css'));
    stream.pipe(serving ? connect.reload() : livereload());
}

function svg(src) {
    var inline = src.svg.inline || false;
    return gulp.src(src.src + '/svg/*.svg')
        .pipe(rename({prefix: 'shape-'}))
        .pipe(svgmin())
        .pipe(svgstore({
            inlineSvg: inline
        }))
        .pipe(cheerio({
            run: function ($) {
                if (!inline) {
                    $('svg').attr('style', 'display:none');
                }
            },
            parserOptions: {xmlMode: true}
        }))
        .pipe(rename('shapes.svg'))
        .pipe(gulp.dest(src.dest + '/svg'))
        .pipe(serving ? connect.reload() : livereload());
}

function js(src) {
    var stream, vendors = [], scripts = [], stream;

    if (!src.js) {
        return;
    }

    /**
     * Vendor files
     */
    (src.js.vendor || []).forEach(function (item) {
        vendors.push(item);
    });
    if (vendors) {
        gulp.src(vendors)
            .pipe(uglify().on('error', function(err) {
                console.log(err.message);
            }))
            .pipe(concat('vendor.js'))
            .pipe(gulp.dest(src.dest + '/js'));
    }

    /**
     * Own code
     */
    (src.js.scripts || []).forEach(function (item) {
        scripts.push(src.src + '/js/' + item);
    });

    if (!scripts.length) {
        return;
    }

{'fraction_non_alphanumeric': 0.18602761982128352, 'fraction_numerical': 0.0008123476848090983, 'mean_word_length': 2.3007149240393208, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '45036', 'n_tokens_mistral': 2483, 'n_tokens_neox': 2441, 'n_words': 437}