old_contents: var gulp    = require('gulp');
  var eslint  = require('gulp-eslint');
  var babel   = require('gulp-babel');
  var mocha   = require('gulp-mocha');
  var del     = require('del');
  
  function clean (cb) {
      del('lib', cb);
  }
  
  function lint () {
      return gulp
          .src([
              'src/**/*.js',
              'test/**/*.js',
              'Gulpfile.js'
          ])
          .pipe(eslint())
          .pipe(eslint.format())
          .pipe(eslint.failAfterError());
  }
  
  function build () {
      return gulp
          .src('src/**/*.js')
          .pipe(babel())
          .pipe(gulp.dest('lib'));
  }
  
  function test () {
      return gulp
          .src('test/test.js')
          .pipe(mocha({
              ui:       'bdd',
              reporter: 'spec',
              timeout:  typeof v8debug === 'undefined' ? 20000 : Infinity // NOTE: disable timeouts in debug
          }));
  }
  
  function preview () {
      var buildReporterPlugin = require('testcafe').embeddingUtils.buildReporterPlugin;
      var pluginFactory       = require('./lib');
      var reporterTestCalls   = require('./test/utils/reporter-test-calls');
      var plugin              = buildReporterPlugin(pluginFactory);
  
      console.log();
  
      reporterTestCalls.forEach(function (call) {
          plugin[call.method].apply(plugin, call.args);
      });
  
      process.exit(0);
  }
  
  exports.clean = clean;
  exports.lint = lint;
  exports.test = gulp.series(test);
  exports.build = gulp.series(build, clean, lint);
  exports.preview = gulp.series(preview, build);
  
new_contents: var gulp    = require('gulp');
  var eslint  = require('gulp-eslint');
  var babel   = require('gulp-babel');
  var mocha   = require('gulp-mocha');
  var del     = require('del');
  
  function clean (cb) {
      del('lib', cb);
  }
  
  function lint () {
      return gulp
          .src([
              'src/**/*.js',
              'test/**/*.js',
              'Gulpfile.js'
          ])
          .pipe(eslint())
          .pipe(eslint.format())
          .pipe(eslint.failAfterError());
  }
  
  function build () {
      return gulp
          .src('src/**/*.js')
          .pipe(babel())
          .pipe(gulp.dest('lib'));
  }
  
  function test () {
      return gulp
          .src('test/test.js')
          .pipe(mocha({
              ui:       'bdd',
              reporter: 'spec',
              timeout:  typeof v8debug === 'undefined' ? 20000 : Infinity // NOTE: disable timeouts in debug
          }));
  }
  
  function preview () {
      var buildReporterPlugin = require('testcafe').embeddingUtils.buildReporterPlugin;
      var pluginFactory       = require('./lib');
      var reporterTestCalls   = require('./test/utils/reporter-test-calls');
      var plugin              = buildReporterPlugin(pluginFactory);
  
      console.log();
  
      reporterTestCalls.forEach(function (call) {
          plugin[call.method].apply(plugin, call.args);
      });
  
      process.exit(0);
  }
  
  exports.clean = clean;
  exports.lint = lint;
  exports.test = gulp.series(test);
  exports.build = gulp.series(clean, build, lint);
  exports.preview = gulp.series(preview, build);
  
subject: Fix Gulpfile: Clean Before Build