text: var gulp = require('gulp');
  var karma = require('karma').server;
  var concat = require('gulp-concat');
  var uglify = require('gulp-uglify');
  var rename = require('gulp-rename');
  var path = require('path');
  var plumber = require('gulp-plumber');
  var runSequence = require('run-sequence');
  var jshint = require('gulp-jshint');
  
  /**
   * File patterns
   **/
  
  // Root directory
  var rootDirectory = path.resolve('./');
  
  // Source directory for build process
  var sourceDirectory = path.join(rootDirectory, './src');
  
  var sourceFiles = [
    // Make sure module files are handled first
    path.join(sourceDirectory, '/**/*.module.js'),
  
    // Then add all JavaScript files
    path.join(sourceDirectory, '/**/*.js')
  ];
  
  var lintFiles = [
    'gulpfile.js',
    // Karma configuration
    'karma-*.conf.js'
  ].concat(sourceFiles);
  
  gulp.task('build', function() {
    gulp.src(sourceFiles)
      .pipe(plumber())
      .pipe(concat('articler.js'))
      .pipe(gulp.dest('./dist/'))
      .pipe(uglify())
      .pipe(rename('articler.min.js'))
      .pipe(gulp.dest('./dist'));
  });
  
  /**
   * Process
   */
  gulp.task('process-all', function (done) {
    runSequence('jshint', 'test', 'build', done);
  });
  
  /**
   * Watch task
   */
  gulp.task('watch', function () {
  
    // Watch JavaScript files
    gulp.watch(sourceFiles, ['process-all']);
  });
  
  /**
   * Validate source JavaScript
   */
  gulp.task('jshint', function () {
    return gulp.src(lintFiles)
      .pipe(plumber())
      .pipe(jshint())
      .pipe(jshint.reporter('jshint-stylish'))
      .pipe(jshint.reporter('fail'));
  });
  
  /**
   * Run test once and exit
   */
  gulp.task('test', function (done) {
    runSequence('build');
    karma.start({
      configFile: __dirname + '/karma-dist-minified.conf.js',
      singleRun: true
    }, done);
  });
  
  gulp.task('default', function () {
    runSequence('process-all', 'watch');
  });
  