const gulp = require('gulp')
  , concat = require('gulp-concat')
  , sourcemaps = require('gulp-sourcemaps')
  , source = require('vinyl-source-stream')
  , buffer = require('vinyl-buffer')
  , watch = require('gulp-watch')
  , plumber = require('gulp-plumber')
  , browserify = require('browserify')
  , util = require('gulp-util')
  , watchify = require('watchify')
  , babelify = require('babelify');


function compile(watch) {
  const bundler =
    watchify(
      browserify('./src/index.js', { debug: true })
        // for es6 module support
        .add(require.resolve('babelify/polyfill'))
        .transform(babelify)
    )

  function rebundle() {
    bundler.bundle()
      .on('error', util.log.bind(util, 'Browserify Error'))
      .pipe(plumber())
      .pipe(source('c-c-c-combo.js'))
      .pipe(buffer())
      .pipe(sourcemaps.init({ loadMaps: true }))
      .pipe(sourcemaps.write('./'))
      .pipe(gulp.dest('./dist'))
  }

  rebundle()

  if (watch) {
    bundler.on('update', function() {
      console.log('*** Changes detected! Rebundling...');
      rebundle();
    });
  }
}

gulp.task('default', function() {
  compile(true)
});

@@ -26,44 +26,8 @@
 p')%0A
-  , concat = require('gulp-concat')%0A
   , 
@@ -66,16 +66,16 @@
 emaps')%0A
+
   , sour
@@ -151,42 +151,8 @@
 r')%0A
-  , watch = require('gulp-watch')%0A
   , 
@@ -287,24 +287,24 @@
 'watchify')%0A
-
   , babelify
@@ -325,16 +325,50 @@
 belify')
+%0A  , shell = require('gulp-shell')
 ;%0A%0A%0Afunc
@@ -1113,12 +1113,61 @@
 e(true)%0A%7D);%0A
+%0Agulp.task('test', shell.task(%5B%0A  'npm test'%0A%5D))%0A

update gulpfile