import runSequence from 'run-sequence';

class Default extends Task {
  constructor() {
    super('default');

    this.beforeStart();

    let taskName = config.cache
      ? 'cache'
      : 'build';
    this.buildTask = config.production
      ? taskName
      : 'serve';
  }
  getSpriteTasks() {
    let tasks = [];

    if (config.sprites.image.length) {
      tasks.push('sprites');
    }
    if (config.sprites.svg.length) {
      tasks.push('svg');
    }

    return tasks;
  }
  beforeStart() {
    gulp.task('start', () => {
      config.beforeTask();
    });

    gulp.task('task:before', () => {
      return new Promise(resolve => {
        runSequence('start', [
          'clean', 'wiredep'
        ], this.getSpriteTasks(), resolve);
      });
    });
  }
  afterEnd() {
    let deps = config.useDefault
      ? [this.buildTask]
      : [];

    gulp.task('end', () => {
      config.afterTask();
    });

    gulp.task('task:after', deps, () => {
      return new Promise(resolve => {
        if (BalmJS.recipes.length) {
          runSequence(BalmJS.recipes, 'end', resolve);
        } else {
          runSequence('end', resolve);
        }
      });
    });
  }
  get deps() {
    return ['task:before'];
  }
  get fn() {
    return () => {
      this.afterEnd();

      gulp.start('task:after');
    };
  }
}

export default Default;

@@ -1,8 +1,35 @@
+/* eslint no-console: 0 */%0A
 import r
@@ -61,16 +61,45 @@
 ence';%0A%0A
+const TIME = 'BalmJS Time';%0A%0A
 class De
@@ -575,32 +575,58 @@
 start', () =%3E %7B%0A
+      console.time(TIME);%0A
       config.bef
@@ -953,32 +953,32 @@
 ('end', () =%3E %7B%0A
-
       config.aft
@@ -979,32 +979,61 @@
 ig.afterTask();%0A
+      console.timeEnd(TIME);%0A
     %7D);%0A%0A    gul

add time