<commit_before>//TODO: Use gulp 4.
const gulp        = require('gulp');
const $           = require('gulp-load-plugins')();
const runSequence = require('run-sequence').use(gulp);

var watching = false;

gulp.on('stop', function () {
    if (!watching) {
        process.nextTick(function () {
            process.exit(0);
        });
    }
});

function onError(err) {
    var self = this;
    return $.notify.onError(function () {
        $.util.beep();
        $.util.log(err.toString());
        if (err.stack) {
            $.util.log('Stack trace', err.stack.toString());
        }
        self.emit('end');
        return 'Error: <%= error.message %>';
    })(err);
}

var options = {
    react: {
        source: 'views/*.js',
        target: 'compiled/views',
        config: { stage: 0 }
    },
    typeScript: {
        source: 'src/**/*.ts',
        target: 'compiled',
        config: $.typescript.createProject({
            typescript: require('typescript'),
            target: 'ES5',
            module: 'commonjs',
            noImplicitAny: true,
            removeComments: true,
            preserveConstEnums: true,
            sourceMap: true,
            outDir: 'compiled'
        })
    },
    sass: {
        source: ['stylesheets/*.scss', 'decorators/*.scss'],
        target: {
            directory: 'compiled',
            fileName: 'all.css'
        },
        config: {
            errLogToConsole: true
        }
    }
};

gulp.task('typescript', function () {
    return gulp.src(options.typeScript.source)
               .pipe($.cached('ts'))
               .pipe($.typescript(options.typeScript.config).on("error", onError))
               .pipe(gulp.dest(options.typeScript.target));
});

gulp.task('sass', function () {
    return gulp.src(options.sass.source)
               .pipe($.cached('sass'))
               .pipe($.sass(options.sass.config).on("error", onError))
               .pipe($.concat(options.sass.target.fileName))
               .pipe(gulp.dest(options.sass.target.directory))
               .pipe($.livereload());
});

gulp.task('react', function () {
    return gulp.src(options.react.source)
               .pipe($.cached('react'))
               .pipe($.babel(options.react.config).on("error", onError))
               .pipe($.react().on("error", onError))
               .pipe(gulp.dest(options.react.target));

});


gulp.task('clean', function (cb) {
    require('del')([options.typeScript.target + '/**'], cb);
});

gulp.task('watch', function (cb) {
    watching = true;
    $.livereload.listen();<commit_msg>Notify when the compilation has finished.<commit_after>//TODO: Use gulp 4.
const gulp        = require('gulp');
const $           = require('gulp-load-plugins')();
const runSequence = require('run-sequence').use(gulp);

var watching = false;

gulp.on('stop', function () {
    if (!watching) {
        process.nextTick(function () {
            process.exit(0);
        });
    }
});

function onError(err) {
    var self = this;
    return $.notify.onError(function () {
        $.util.beep();
        $.util.log(err.toString());
        if (err.stack) {
            $.util.log('Stack trace', err.stack.toString());
        }
        self.emit('end');
        return 'Error: <%= error.message %>';
    })(err);
}

var options = {
    react: {
        source: 'views/*.js',
        target: 'compiled/views',
        config: { stage: 0 }
    },
    typeScript: {
        source: 'src/**/*.ts',
        target: 'compiled',
        config: $.typescript.createProject({
            typescript: require('typescript'),
            target: 'ES5',
            module: 'commonjs',
            noImplicitAny: true,
            removeComments: true,
            preserveConstEnums: true,
            sourceMap: true,
            outDir: 'compiled'
        })
    },
    sass: {
        source: ['stylesheets/*.scss', 'decorators/*.scss'],
        target: {
            directory: 'compiled',
            fileName: 'all.css'
        },
        config: {
            errLogToConsole: true
        }
    }
};

gulp.task('typescript', function () {
    return gulp.src(options.typeScript.source)
               .pipe($.cached('ts'))
               .pipe($.typescript(options.typeScript.config).on("error", onError))
               .pipe(gulp.dest(options.typeScript.target))
               .pipe($.notify("TypeScript has been compiled."));
});

gulp.task('sass', function () {
    return gulp.src(options.sass.source)
               .pipe($.cached('sass'))
               .pipe($.sass(options.sass.config).on("error", onError))
               .pipe($.concat(options.sass.target.fileName))
               .pipe(gulp.dest(options.sass.target.directory))
               .pipe($.livereload())
               .pipe($.notify("SCSS has been compiled."));
});

gulp.task('react', function () {
    return gulp.src(options.react.source)
               .pipe($.cached('react'))
               .pipe($.babel(options.react.config).on("error", onError))
               .pipe($.react().on("error", onError))
               .pipe(gulp.dest(options.react.target))
               .pipe($.notify("React has been compiled."));

});


gulp.task('clean', function (cb) {
    require('del')([options.typeScript.target + '/**'], cb);
});

gulp.task('watch', function (cb) {
    watching = true;
    $.livereload.listen();
{'fraction_non_alphanumeric': 0.17864476386036962, 'fraction_numerical': 0.0014933731566175099, 'mean_word_length': 1.9618573797678276, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3565631', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1612, 'n_words': 264}