<commit_before>/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Useful tasks:
//
//      $ gulp mocha                        - run mocha tests
//      $ gulp qunit                        - run qunit test page
//      $ gulp playground                   - run Hammerhead playground page
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var babel      = require('babel');
var gulpBabel  = require('gulp-babel');
var del        = require('del');
var eslint     = require('gulp-eslint');
var fs         = require('fs');
var gulp       = require('gulp');
var mocha      = require('gulp-mocha');
var mustache   = require('gulp-mustache');
var rename     = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
//var uglify     = require('gulp-uglify');
var webmake    = require('gulp-webmake');
var chalk      = require('chalk');
var Promise    = require('promise');

function makePromise (fn) {
    return { then: fn };
}

var HangPromise = makePromise(function () {
    //Never resolves =)
});

gulp.task('clean', function () {
    return makePromise(function (done) {
        del(['./lib'], done);
    });
});

gulp.task('templates', function () {
    return gulp
        .src('./src/client/templates/task.js.mustache', { silent: false })
        .pipe(gulp.dest('./lib/client'));
});

gulp.task('client-scripts', ['client-scripts-bundle'], function () {
    return gulp.src('./src/client/templates/hammerhead.js.mustache')
        .pipe(mustache({
            source:    fs.readFileSync('./lib/client/hammerhead.js').toString(),
            sourceMap: ''
        }))
        .pipe(rename('hammerhead.js'))
        .pipe(gulp.dest('./lib/client'));
});

gulp.task('client-scripts-bundle', function () {
    return gulp.src('./src/client/hammerhead.js')
        .pipe(webmake({
            sourceMap: false,
            transform: function (filename, code) {
                var transformed = babel.transform(code, { sourceMap: false, blacklist: ['strict'] });

                return {
                    code:      transformed.code,
                    sourceMap: transformed.map
                };
            }
        }))
        .pipe(gulp.dest('./lib/client'));
});

gulp.task('server-scripts', function () {
    return gulp.src(['./src/**/*.js', '!./src/client/**/*.js'])
        .pipe(sourcemaps.init())
        .pipe(gulpBabel())
        .pipe(sourcemaps.write('.', {
            includeContent: true,
            sourceRoot:     '../src'
        }))
        .pipe(gulp.dest('lib/'));
});

gulp.task('lint', function () {
    return gulp
        .src([
            './src/**/*.js',
            '!./src/client/json.js',
            '!./src/processing/js/parsing-tools.js',
            './test/mocha/fixtures/**/*.js',
            './test/qunit/fixtures/**/*.js',
            'Gulpfile.js'
        ])
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failAfterError());
});

gulp.task('build', ['client-scripts', 'server-scripts', 'templates', 'lint']);

gulp.task('mocha', ['build'], function () {
    return gulp.src('./test/mocha/*-test.js', { read: false })
        .pipe(mocha({
            ui:       'bdd',
            reporter: 'spec',
            // NOTE: disable timeouts in debug
            timeout:  typeof v8debug === 'undefined' ? 2000 : Infinity
        }));
});

gulp.task('qunit', ['build'], function () {
    gulp.watch(['./src/**', './test/qunit/fixtures/**'], ['build']);

    require('./test/qunit/server.js').start();

    return HangPromise;
});

gulp.task('playground', ['build'], function () {
    require('./test/playground/server.js').start();

    return HangPromise;
});

gulp.task('travis', [process.env.GULP_TASK || '']);

(function SAUCE_LABS_QUNIT_TESTING () {
    var SauceTunnel = require('sauce-tunnel');
    var QUnitRunner = require('./test/qunit/sauce-labs-runner');
    var qunitServer = require('./test/qunit/server.js');

    var SAUCE_USERNAME = process.env.SAUCE_USERNAME || '';
    var SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY || '';

    var RUN_TESTS_URL = '/run-dir?dir=fixtures';
    var BROWSERS      = [
        {
            platform:    'Windows 10',
            browserName: 'chrome'
        },
        {
            platform:    'Windows 10',
            browserName: 'firefox'
        },
        {
            platform:    'Windows 10',
            browserName: 'internet explorer',
            version:     '11.0'
        },
        {
            platform:    'Windows 8',
            browserName: 'internet explorer',<commit_msg>Get rid of the home-made promises<commit_after>/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Useful tasks:
//
//      $ gulp mocha                        - run mocha tests
//      $ gulp qunit                        - run qunit test page
//      $ gulp playground                   - run Hammerhead playground page
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var babel      = require('babel');
var gulpBabel  = require('gulp-babel');
var del        = require('del');
var eslint     = require('gulp-eslint');
var fs         = require('fs');
var gulp       = require('gulp');
var mocha      = require('gulp-mocha');
var mustache   = require('gulp-mustache');
var rename     = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var webmake    = require('gulp-webmake');
var chalk      = require('chalk');
var Promise    = require('promise');

gulp.task('clean', function () {
    return new Promise(function (resolve) {
        del(['./lib'], resolve);
    });
});

gulp.task('templates', function () {
    return gulp
        .src('./src/client/templates/task.js.mustache', { silent: false })
        .pipe(gulp.dest('./lib/client'));
});

gulp.task('client-scripts', ['client-scripts-bundle'], function () {
    return gulp.src('./src/client/templates/hammerhead.js.mustache')
        .pipe(mustache({
            source:    fs.readFileSync('./lib/client/hammerhead.js').toString(),
            sourceMap: ''
        }))
        .pipe(rename('hammerhead.js'))
        .pipe(gulp.dest('./lib/client'));
});

gulp.task('client-scripts-bundle', function () {
    return gulp.src('./src/client/hammerhead.js')
        .pipe(webmake({
            sourceMap: false,
            transform: function (filename, code) {
                var transformed = babel.transform(code, { sourceMap: false, blacklist: ['strict'] });

                return {
                    code:      transformed.code,
                    sourceMap: transformed.map
                };
            }
        }))
        .pipe(gulp.dest('./lib/client'));
});

gulp.task('server-scripts', function () {
    return gulp.src(['./src/**/*.js', '!./src/client/**/*.js'])
        .pipe(sourcemaps.init())
        .pipe(gulpBabel())
        .pipe(sourcemaps.write('.', {
            includeContent: true,
            sourceRoot:     '../src'
        }))
        .pipe(gulp.dest('lib/'));
});

gulp.task('lint', function () {
    return gulp
        .src([
            './src/**/*.js',
            '!./src/client/json.js',
            '!./src/processing/js/parsing-tools.js',
            './test/mocha/fixtures/**/*.js',
            './test/qunit/fixtures/**/*.js',
            'Gulpfile.js'
        ])
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failAfterError());
});

gulp.task('build', ['client-scripts', 'server-scripts', 'templates', 'lint']);

gulp.task('mocha', ['build'], function () {
    return gulp.src('./test/mocha/*-test.js', { read: false })
        .pipe(mocha({
            ui:       'bdd',
            reporter: 'spec',
            // NOTE: disable timeouts in debug
            timeout:  typeof v8debug === 'undefined' ? 2000 : Infinity
        }));
});

gulp.task('qunit', ['build'], function () {
    gulp.watch(['./src/**', './test/qunit/fixtures/**'], ['build']);

    require('./test/qunit/server.js').start();

    return new Promise(function () {
    });
});

gulp.task('playground', ['build'], function () {
    require('./test/playground/server.js').start();

    return new Promise(function () {
    });
});

gulp.task('travis', [process.env.GULP_TASK || '']);

(function SAUCE_LABS_QUNIT_TESTING () {
    var SauceTunnel = require('sauce-tunnel');
    var QUnitRunner = require('./test/qunit/sauce-labs-runner');
    var qunitServer = require('./test/qunit/server.js');

    var SAUCE_USERNAME   = process.env.SAUCE_USERNAME || '';
    var SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY || '';

    var RUN_TESTS_URL = '/run-dir?dir=fixtures';
    var BROWSERS      = [
        {
            platform:    'Windows 10',
            browserName: 'chrome'
        },
        {
            platform:    'Windows 10',
            browserName: 'firefox'
        },
        {
            platform:    'Windows 10',
            browserName: 'internet explorer',
            version:     '11.0'
        },
        {
            platform:    'Windows 8',
            browserName: 'internet explorer',
{'fraction_non_alphanumeric': 0.2246924239153896, 'fraction_numerical': 0.0032376429958989855, 'mean_word_length': 1.7183924904664125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6361110', 'n_tokens_mistral': 2772, 'n_tokens_neox': 2690, 'n_words': 475}