<commit_before>var gulp = require('gulp');
var mocha = require('gulp-mocha');
var file = require('gulp-file');
var istanbul = require('gulp-istanbul');
var babel = require("gulp-babel");
var webpack = require('webpack-stream');
var exec = require('child_process').exec;

var browserify = require('./support/browserify.js');

gulp.task('build-webpack', function() {
  return gulp.src('lib/*.js') 
    .pipe(webpack({
      entry: './lib/index.js',
      output: {
        filename: 'socket.io.js',
      },
    }))
    .pipe(babel({
      presets: ['es2015'],
      compact: false
    }))
    .pipe(gulp.dest('./'));
});

// By default, individual js files are transformed by babel and exported to /dist
gulp.task("babel", function () {
  return gulp.src("lib/*.js")
    .pipe(babel())
    .pipe(gulp.dest("dist"));
});

gulp.task('build', function(){
  browserify(function(err, out){
    if(err){
      throw err;
    }else{
      gulp.src('')
        .pipe(file('socket.io.js', out))
        .pipe(gulp.dest('./'));
    }
  });
});

gulp.task('test', [process.env.BROWSER_NAME ? 'test-zuul' : 'test-node'], function(){
});

gulp.task('test-zuul', function(){
  if(process.env.BROWSER_PLATFORM){
    exec('./node_modules/zuul/bin/zuul ' +
        '--browser-name ' + process.env.BROWSER_NAME + ' ' +
        '--browser-version ' + process.env.BROWSER_VERSION + ' ' +
        '--browser-platform ' +process.env.BROWSER_PLATFORM + ' ' +
        'test/index.js',
      function(err, stdout, stderr){
        console.log(stdout);
        console.error(stderr);
    });
  }else{
    exec('./node_modules/zuul/bin/zuul ' +
      '--browser-name ' + process.env.BROWSER_NAME + ' ' +
      '--browser-version ' + process.env.BROWSER_VERSION + ' ' +
      'test/index.js',
      function(err, stdout, stderr){
        console.log(stdout);
        console.error(stderr);
      });
  }
});

gulp.task('test-node', function(){
  gulp.src(['test/*.js', 'test/support/*.js'])
    .pipe(mocha({
      reporter: 'dot'
    }))
    .once('error', function () {
      process.exit(1);
    })
    .once('end', function () {
      process.exit();
    });
});

gulp.task('istanbul-pre-test', function () {
  return gulp.src(['lib/**/*.js'])
    // Covering files
    .pipe(istanbul())
    // Force `require` to return covered files
    .pipe(istanbul.hookRequire());
});

gulp.task('test-cov', ['istanbul-pre-test'], function(){
  gulp.src(['test/*.js', 'test/support/*.js'])
    .pipe(mocha({
      reporter: 'dot'
    }))
    .pipe(istanbul.writeReports())
    .once('error', function (){
      process.exit(1);
    })
    .once('end', function (){
      process.exit();
    });
});
<commit_msg>Expose io variable to global when bundling with webpack<commit_after>var gulp = require('gulp');
var mocha = require('gulp-mocha');
var file = require('gulp-file');
var istanbul = require('gulp-istanbul');
var babel = require("gulp-babel");
var webpack = require('webpack-stream');
var exec = require('child_process').exec;

var browserify = require('./support/browserify.js');

gulp.task('build-webpack', function() {
  return gulp.src('lib/*.js') 
    .pipe(webpack({
      entry: './lib/index.js',
      output: {
        library: 'io',
        libraryTarget: 'umd',
        filename: 'socket.io.js',
      },
      externals: {
          'global': glob()
        }
    }))
    .pipe(gulp.dest('./'));
});

// By default, individual js files are transformed by babel and exported to /dist
gulp.task("babel", function () {
  return gulp.src("lib/*.js")
    .pipe(babel())
    .pipe(gulp.dest("dist"));
});

gulp.task('build', function(){
  browserify(function(err, out){
    if(err){
      throw err;
    }else{
      gulp.src('')
        .pipe(file('socket.io.js', out))
        .pipe(gulp.dest('./'));
    }
  });
});

gulp.task('test', [process.env.BROWSER_NAME ? 'test-zuul' : 'test-node'], function(){
});

gulp.task('test-zuul', function(){
  if(process.env.BROWSER_PLATFORM){
    exec('./node_modules/zuul/bin/zuul ' +
        '--browser-name ' + process.env.BROWSER_NAME + ' ' +
        '--browser-version ' + process.env.BROWSER_VERSION + ' ' +
        '--browser-platform ' +process.env.BROWSER_PLATFORM + ' ' +
        'test/index.js',
      function(err, stdout, stderr){
        console.log(stdout);
        console.error(stderr);
    });
  }else{
    exec('./node_modules/zuul/bin/zuul ' +
      '--browser-name ' + process.env.BROWSER_NAME + ' ' +
      '--browser-version ' + process.env.BROWSER_VERSION + ' ' +
      'test/index.js',
      function(err, stdout, stderr){
        console.log(stdout);
        console.error(stderr);
      });
  }
});

gulp.task('test-node', function(){
  gulp.src(['test/*.js', 'test/support/*.js'])
    .pipe(mocha({
      reporter: 'dot'
    }))
    .once('error', function () {
      process.exit(1);
    })
    .once('end', function () {
      process.exit();
    });
});

gulp.task('istanbul-pre-test', function () {
  return gulp.src(['lib/**/*.js'])
    // Covering files
    .pipe(istanbul())
    // Force `require` to return covered files
    .pipe(istanbul.hookRequire());
});

gulp.task('test-cov', ['istanbul-pre-test'], function(){
  gulp.src(['test/*.js', 'test/support/*.js'])
    .pipe(mocha({
      reporter: 'dot'
    }))
    .pipe(istanbul.writeReports())
    .once('error', function (){
      process.exit(1);
    })
    .once('end', function (){
      process.exit();
    });
});

/**
 * Populates `global`.
 *
 * @api private
 */

function glob(){
  return 'typeof self !== "undefined" ? self : '
    + 'typeof window !== "undefined" ? window : '
    + 'typeof global !== "undefined" ? global : {}';
}
{'fraction_non_alphanumeric': 0.21313506815365552, 'fraction_numerical': 0.0014161798548415648, 'mean_word_length': 2.6976439790575917, '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': '6144707', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1953, 'n_words': 321}