text: /**
   * Created by vagrant on 8/10/16.
   */
  
  var gulp = require('gulp'),
      args = require('yargs').argv,
      config = require('./gulp.config')(),
      del = require('del');
      $ = require('gulp-load-plugins')({lazy: true});
  
  /*
      Tasks
  */
  gulp.task('vet', function () {
      log('Analyzing JS source files with JSHint and JSCS');
  
      return gulp
          .src(config.alljs)
          .pipe($.if(args.verbose, $.print()))
          .pipe($.jscs())
          .pipe($.jshint())
          .pipe($.jshint.reporter('jshint-stylish', {verbose: true}))
          .pipe($.jshint.reporter('fail'));
  });
  
  gulp.task('styles', ['clean-styles'], function() {
      log('Compiling SCSS --> CSS');
      
      return gulp
          .src(config.scss)
          .pipe($.plumber())
          .pipe($.sass())
          .pipe($.autoprefixer({ browsers: ['last 2 version', '> 5%'] }))
          .pipe(gulp.dest(config.css_drop));
  });
  
  gulp.task('clean-styles', function(done) {
      var files = config.temp + '**/*.css';
      clean(files, done);
  });
  
  gulp.task('wiredep', function() {
      log('Wire up the bower css js and app js into index.html');
  
      var options = config.getWiredepDefaultOptions();
      var wiredep = require('wiredep').stream;
  
      return gulp
          .src(config.index)
          .pipe(wiredep(options))
          .pipe($.inject(gulp.src(config.js)))
          .pipe($.replace('/app/', ''))
          .pipe(gulp.dest(config.client));
  });
  
  gulp.task('inject', ['wiredep', 'styles'], function() {
      log('Inject app custom css into index.html');
  
      return gulp
          .src(config.index)
          .pipe($.inject(gulp.src(config.css)))
          .pipe($.replace('/app/', ''))
          .pipe(gulp.dest(config.client));
  });
  
  ///////////////
  
  function clean(path, done) {
      log('Cleaning: ' + $.util.colors.blue(path));
      del(path);
      done();
  }
  
  /* 
      Custom msg log()
   */
  
  function log(msg) {
      if (typeof(msg) === 'object') {
          for (var item in msg) {
              if (msg.hasOwnProperty(item)) {
                  $.util.log($.util.colors.blue(msg[item]));
              }
          }
      } else {
          $.util.log($.util.colors.blue(msg));
      }
  }