<commit_before>/**
 * Task runner definitions file.
 */

var fs = require('fs');
var path = require('path');
var del = require('del');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var shell = require('shelljs');

var browserify = require('browserify');
var reactify = require('reactify');

var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var istanbul = require('gulp-istanbul');
var mocha = require('gulp-mocha');
var sourcemaps = require('gulp-sourcemaps');
var jshint = require('gulp-jshint');
var symlink = require('gulp-symlink');
var react = require('gulp-react');

var traceur = require('gulp-traceur-compiler');

var gollePackage = require('./package.json');

/**
 * Generates a bundle name for the current version of GOLL-E.
 */
var getBundleName = function ( descriptors ) {
    'use strict';

    // Default value - empty array.
    descriptors = descriptors || [];

    var name = gollePackage.name;
    var extra = descriptors.reduce(function (previousValue, currentValue) {
        return previousValue + "." + currentValue;
    }, '');

    return extra === '' ? name  : name + extra;
};

var paths = {
    sourceFiles: [path.join('lib', '**', '*.js'),
                  path.join('lib', '**', '*', '*.jsx')],
    testFiles: [path.join('test', '**', 'test-*.js')],
    distributables: [path.join('dist', '**', '*')],
    distDir: 'dist',
    coverageDir: 'coverage'
};

/**
 * Default mocha test runner setup.
 */
var mochaDefault = mocha({
    reporter: 'spec',
    globals: {
        should: require('should')
    }
});

/**
 * Task definition for generating parsers using jison. 
 */
gulp.task('jison', [], function () {
    'use strict';

    // There are three parsers to generate.
    // For now, we only care about the content language parser.
    var parserNames = ['gcl'];

    // Start generating parsers.
    parserNames.forEach(function (value, index, array) {
        // Build out complete paths for the grammar and lexer files.
        var grammarFile = path.join('jison', value + '.jison');
        var lexerFile = grammarFile + 'lex';
        var destination = 'jison';
        var jisonCmdPath = path.join('node_modules', 'jison', 'lib', 'cli.js');
    
        // Build up the shell command to run to generate the parser.
        var cmd = jisonCmdPath + ' ' + grammarFile + ' ' + lexerFile + ' --module-type commonjs';

        // Run the command.
        shell.exec(cmd);
        shell.mv('-f', value + '.js', destination); 
    });
});

/**
 * Task definition for performing static analysis against the lib directory.
 */
gulp.task('lint', ['build'], function () {
    'use strict';

    return gulp.src(paths.sourceFiles)
        .pipe(react())
        .pipe(jshint())
        .pipe(jshint.reporter('default'))
        .pipe(jshint.reporter('fail'));
});

/**
 * Task definition for running unit tests.
 */
gulp.task('mocha', ['lint', 'jison'], function () {
    'use strict';
    
    return gulp.src(paths.testFiles, { 
        read: false
    })
    .pipe(traceur())
    .pipe(mochaDefault);
});

/**<commit_msg>Replaced jshint with eslint in the lint task.<commit_after>/**
 * Task runner definitions file.
 */

var fs = require('fs');
var path = require('path');
var del = require('del');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var shell = require('shelljs');

var browserify = require('browserify');
var reactify = require('reactify');

var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var istanbul = require('gulp-istanbul');
var mocha = require('gulp-mocha');
var sourcemaps = require('gulp-sourcemaps');
var eslint = require('gulp-eslint');
var symlink = require('gulp-symlink');
var react = require('gulp-react');

var traceur = require('gulp-traceur-compiler');

var gollePackage = require('./package.json');

/**
 * Generates a bundle name for the current version of GOLL-E.
 */
var getBundleName = function ( descriptors ) {
    'use strict';

    // Default value - empty array.
    descriptors = descriptors || [];

    var name = gollePackage.name;
    var extra = descriptors.reduce(function (previousValue, currentValue) {
        return previousValue + "." + currentValue;
    }, '');

    return extra === '' ? name  : name + extra;
};

var paths = {
    sourceFiles: [path.join('lib', '**', '*.js'),
                  path.join('lib', '**', '*', '*.jsx')],
    testFiles: [path.join('test', '**', 'test-*.js')],
    distributables: [path.join('dist', '**', '*')],
    distDir: 'dist',
    coverageDir: 'coverage'
};

/**
 * Default mocha test runner setup.
 */
var mochaDefault = mocha({
    reporter: 'spec',
    globals: {
        should: require('should')
    }
});

/**
 * Task definition for generating parsers using jison. 
 */
gulp.task('jison', [], function () {
    'use strict';

    // There are three parsers to generate.
    // For now, we only care about the content language parser.
    var parserNames = ['gcl'];

    // Start generating parsers.
    parserNames.forEach(function (value, index, array) {
        // Build out complete paths for the grammar and lexer files.
        var grammarFile = path.join('jison', value + '.jison');
        var lexerFile = grammarFile + 'lex';
        var destination = 'jison';
        var jisonCmdPath = path.join('node_modules', 'jison', 'lib', 'cli.js');
    
        // Build up the shell command to run to generate the parser.
        var cmd = jisonCmdPath + ' ' + grammarFile + ' ' + lexerFile + ' --module-type commonjs';

        // Run the command.
        shell.exec(cmd);
        shell.mv('-f', value + '.js', destination); 
    });
});

/**
 *  Task definition for performing static analysis against the lib directory.
 **/
gulp.task('lint', ['build'], function () {
    'use strict';

    return gulp.src(paths.sourceFiles)
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failOnError());
});


/**
 * Task definition for running unit tests.
 */
gulp.task('mocha', ['lint', 'jison'], function () {
    'use strict';
    
    return gulp.src(paths.testFiles, { 
        read: false
    })
    .pipe(traceur())
    .pipe(mochaDefault);
});

/**
{'fraction_non_alphanumeric': 0.17297899427116487, 'fraction_numerical': 0.0, 'mean_word_length': 3.021113243761996, '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': '592971', 'n_tokens_mistral': 1979, 'n_tokens_neox': 1920, 'n_words': 524}