import Start from 'start';
import reporter from 'start-pretty-reporter';
import env from 'start-env';
import files from 'start-files';
import watch from 'start-watch';
import clean from 'start-clean';
import read from 'start-read';
import babel from 'start-babel';
import write from 'start-write';
import eslint from 'start-eslint';
import mocha from 'start-mocha';
import * as istanbul from 'start-istanbul';
import codecov from 'start-codecov';

import babelIstanbul from 'babel-istanbul';

export const start = Start(reporter());

export function build() {
    return start(
        env('production'),
        files('build/'),
        clean(),
        files('lib/**/*.js'),
        read(),
        babel(),
        write('build/')
    );
}

export function dev() {
    return start(
        env('development'),
        files('build/'),
        clean(),
        files('lib/**/*.js'),
        watch(file => start(
            files(file),
            read(),
            babel(),
            write('build/')
        ))
    );
}

export function lint() {
    return start(
        env('test'),
        files([ 'lib/**/*.js', 'test/lib/**/*.js' ], { ignore: 'test/fixtures/**' }),
        eslint()
    );
}

export function test() {
    return start(
        env('test'),
        files('test/**/*.js', { ignore: 'test/fixtures/**' }),
        mocha()
    );
}

export function tdd() {
    return start(
        files([ 'lib/**/*.js', 'test/**/*.js' ]),
        watch(test)
    );
}

export function coverage() {
    return start(
        env('test'),
        files('coverage/'),
        clean(),
        files('lib/**/*.js'),
        istanbul.instrument(babelIstanbul),
        test,
        istanbul.report([ 'lcovonly', 'html', 'text-summary' ])
    );
}

export function ci() {
    return start(
        lint,
        coverage,
        files('coverage/lcov.info'),
        read(),
        codecov()
    );
}

export function prepush() {
    return start(
        lint,
        coverage
    );
}

@@ -527,16 +527,144 @@
 er());%0A%0A
+export function copyDTS() %7B%0A    return start(%0A        files('lib/**/*.d.ts'),%0A        read(),%0A        write('build/')%0A    );%0A%7D%0A%0A
 export f
@@ -846,32 +846,49 @@
  write('build/')
+,%0A        copyDTS
 %0A    );%0A%7D%0A%0Aexpor

copy d.ts typings to build folder