var gulp   = require('gulp'),
    gutil  = require('gulp-util'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify'),
    rename = require('gulp-rename'),
    karma  = require('gulp-karma'),
    notify = require('gulp-notify');

var jsFiles = [
  './src/angular-moment.js',
  './src/angular-moment.service.js',
  './src/angular-moment.directive.js'
];

// Task to run during development
gulp.task('develop', function() {
  karmaAction = 'watch';
  gulp.watch(jsFiles, ['js']);
  karmaTest('watch');
});

// Task to build to dist folder
gulp.task('build', ['js'], function() {
  karmaTest('run');
});


// Subtasks
////////////

gulp.task('js', function() {
  gulp.src(jsFiles)
    .pipe(concat("angular-moment.js"))
    .pipe(gulp.dest('./dist/'))
    .pipe(rename({ suffix: '.min' }))
    .pipe(uglify({
      outSourceMaps: true,
      preserveComments: 'some'
    }))
    .pipe(gulp.dest('./dist'));
    // .pipe(notify({ message: 'Scripts task complete' }));
});

function karmaTest(action) {
  return gulp.src('./defined-in-karma.conf.js')
    .pipe(karma({
      configFile: 'karma.conf.js',
      action: action
    }));
}
var gulp   = require('gulp'),
    gutil  = require('gulp-util'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify'),
    rename = require('gulp-rename'),
    karma  = require('gulp-karma'),
    notify = require('gulp-notify');

gulp.task('default', function() {
  gulp.run('scripts', 'test');
});

gulp.task('watch', function() {
  gulp.watch('./src/*.js', function(event) {
    gulp.run('scripts');
  });
  gulp.run('test-watch');
});

gulp.task('scripts', function() {
  gulp.src([
      './src/angular-moment.js',
      './src/angular-moment.service.js',
      './src/angular-moment.directive.js'
    ])
    .pipe(concat("angular-moment.js"))
    .pipe(gulp.dest('./dist/'))
    .pipe(rename({ suffix: '.min' }))
    .pipe(uglify({
      outSourceMaps: true,
      preserveComments: 'some'
    }))
    .pipe(gulp.dest('./dist'))
    .pipe(notify({ message: 'Scripts task complete' }));
});

// Karma testing
gulp.task('test', function() {
  // Be sure to return the stream
  return gulp.src('./defined-in-karma.conf.js')
    .pipe(karma({
      configFile: 'karma.conf.js',
      action: 'run'
    }));
});

gulp.task('test-watch', function() {
  // Be sure to return the stream
  return gulp.src('./defined-in-karma.conf.js')
    .pipe(karma({
      configFile: 'karma.conf.js',
      action: 'watch'
    }));
});
--- 
+++ 
@@ -6,30 +6,23 @@
     karma  = require('gulp-karma'),
     notify = require('gulp-notify');
 
-var jsFiles = [
-  './src/angular-moment.js',
-  './src/angular-moment.service.js',
-  './src/angular-moment.directive.js'
-];
-
-// Task to run during development
-gulp.task('develop', function() {
-  karmaAction = 'watch';
-  gulp.watch(jsFiles, ['js']);
-  karmaTest('watch');
+gulp.task('default', function() {
+  gulp.run('scripts', 'test');
 });
 
-// Task to build to dist folder
-gulp.task('build', ['js'], function() {
-  karmaTest('run');
+gulp.task('watch', function() {
+  gulp.watch('./src/*.js', function(event) {
+    gulp.run('scripts');
+  });
+  gulp.run('test-watch');
 });
 
-
-// Subtasks
-////////////
-
-gulp.task('js', function() {
-  gulp.src(jsFiles)
+gulp.task('scripts', function() {
+  gulp.src([
+      './src/angular-moment.js',
+      './src/angular-moment.service.js',
+      './src/angular-moment.directive.js'
+    ])
     .pipe(concat("angular-moment.js"))
     .pipe(gulp.dest('./dist/'))
     .pipe(rename({ suffix: '.min' }))
@@ -37,14 +30,25 @@
       outSourceMaps: true,
       preserveComments: 'some'
     }))
-    .pipe(gulp.dest('./dist'));
-    // .pipe(notify({ message: 'Scripts task complete' }));
+    .pipe(gulp.dest('./dist'))
+    .pipe(notify({ message: 'Scripts task complete' }));
 });
 
-function karmaTest(action) {
+// Karma testing
+gulp.task('test', function() {
+  // Be sure to return the stream
   return gulp.src('./defined-in-karma.conf.js')
     .pipe(karma({
       configFile: 'karma.conf.js',
-      action: action
+      action: 'run'
     }));
-}
+});
+
+gulp.task('test-watch', function() {
+  // Be sure to return the stream
+  return gulp.src('./defined-in-karma.conf.js')
+    .pipe(karma({
+      configFile: 'karma.conf.js',
+      action: 'watch'
+    }));
+});
Fix gulp file to no longer use deprecated gulp.run
