var gulp = require('gulp');
var sass = require('gulp-sass');
var connect = require('gulp-connect');
var babel = require('gulp-babel');
var minify = require('gulp-minify');
var shell = require('gulp-shell');

// setup the local enviroment
gulp.task('connect', function(){
  connect.server({
    root: 'public',
    livereload: true
  });
});

// compile sass and log errors in the terminal
gulp.task('sass', function () {
  return gulp.src('./sass/styles.scss')
      .pipe(sass({ errLogToConsole: true }))
      .pipe(gulp.dest('./public/css'));
});

// transpile our ES6 javascript into ES5
gulp.task('transpile', function() {
  return gulp.src('./scripts/*.js')
      .pipe(babel({
          presets: ['env']
      }))
      .pipe(gulp.dest('./public/js'))
});

// minify required javascript for dist
gulp.task('minify', function() {
  gulp.src('./public/js/okayNowThis.js')
    .pipe(minify({
        ext:{
            min:'.min.js'
        },
    }))
    .pipe(gulp.dest('./dist/'))
});

// setup the live reload of public files
gulp.task('livereload', function (){
  gulp.src('./public/**/*')
  .pipe(connect.reload());
});

// watch for changes
gulp.task('watch', function () {
  gulp.watch('./sass/**/*.scss', ['sass']);
  gulp.watch('./scripts/**/*.js', ['transpile']);
  gulp.watch('./public/**/*', ['livereload']);
});

// update the GitHub pages subtree branch (by running a basic git command via shell)
gulp.task('pushDemo', () => {
  return gulp.src('*.js', {read: false})
  .pipe(shell([
    'git subtree push --prefix public origin gh-pages'
  ]))
})

// setup the default 'gulp task'
gulp.task('default', ['connect', 'watch', 'sass', 'transpile', 'minify']);

// package the dist folder and update the demo on gh-pages
gulp.task('package', ['pushDemo']);

@@ -761,236 +761,8 @@
 );%0A%0A
-// minify required javascript for dist%0Agulp.task('minify', function() %7B%0A  gulp.src('./public/js/okayNowThis.js')%0A    .pipe(minify(%7B%0A        ext:%7B%0A            min:'.min.js'%0A        %7D,%0A    %7D))%0A    .pipe(gulp.dest('./dist/'))%0A%7D);%0A%0A
 // s
@@ -1195,20 +1195,16 @@
 sk('push
-Demo
 ', () =%3E
@@ -1328,16 +1328,263 @@
 %5D))%0A%7D)%0A%0A
+// minify required javascript for dist%0Agulp.task('minify', function() %7B%0A  return gulp.src('./public/js/okayNowThis.js')%0A      .pipe(minify(%7B%0A          ext:%7B%0A              min:'.min.js'%0A          %7D,%0A      %7D))%0A      .pipe(gulp.dest('./dist/'))%0A%7D);%0A%0A
 // setup
@@ -1673,53 +1673,15 @@
 ile'
-, 'minify'%5D);%0A%0A// package the dist folder and
+%5D);%0A%0A//
  upd
@@ -1693,16 +1693,22 @@
 he demo 
+files 
 on gh-pa
@@ -1726,15 +1726,12 @@
 sk('
-package
+demo
 ', %5B
@@ -1739,12 +1739,82 @@
 push
-Demo
+'%5D);%0A%0A// ready the files for ditrubution /dist/%0Agulp.task('dist', %5B'minify
 '%5D);

make a new gulp task for handling the /dist/ folder