"use strict";
const gulp = require("gulp");
const merge2 = require("merge2");
const sourcemaps = require("gulp-sourcemaps");
const typescript = require("gulp-typescript");

const tslint = require("gulp-tslint");
const typedoc = require("gulp-typedoc");

// use tsconfig.json
const tsProject = typescript.createProject("tsconfig.json");
gulp.task("tsc", () => {
	let tsr = gulp.src("src/**/*.ts")
		.pipe(tsProject());
	return merge2([
		tsr.dts.pipe(gulp.dest("dist/")),
		tsr.js.pipe(sourcemaps.write()).pipe(gulp.dest("dist"))
	]);
});

gulp.task("watch-tsc", ["tsc"], () => {
	gulp.watch("src/**/*.ts", ["tsc"]);
});

gulp.task("tslint", () => {
	return gulp.src("src/**/*.ts")
		.pipe(tslint({
			formatter: "verbose"
		}))
		.pipe(tslint.report());
});

gulp.task("watch-tslint", ["tslint"], () => {
	gulp.watch("src/**/*.ts", ["tslint"]);
});

gulp.task("typedoc", () => {
	return gulp.src("src/**/*.ts")
		.pipe(typedoc({
			module: "commonjs",
			target: "es6",
			out: "docs/",
			name: "parsergenerator"
		}))
});

gulp.task("watch-typedoc", ["typedoc"], () => {
	gulp.watch("src/**/*.ts", ["typedoc"]);
});

gulp.task("default", ["tsc", "tslint", "typedoc"]);
gulp.task("watch", ["watch-tsc", "watch-tslint", "watch-typedoc"]);

@@ -835,32 +835,125 @@
 tslint%22%5D);%0A%7D);%0A%0A
+gulp.task(%22default%22, %5B%22tsc%22, %22tslint%22%5D);%0Agulp.task(%22watch%22, %5B%22watch-tsc%22, %22watch-tslint%22%5D);%0A%0A
 gulp.task(%22typed
@@ -1208,125 +1208,4 @@
 %7D);%0A
-%0Agulp.task(%22default%22, %5B%22tsc%22, %22tslint%22, %22typedoc%22%5D);%0Agulp.task(%22watch%22, %5B%22watch-tsc%22, %22watch-tslint%22, %22watch-typedoc%22%5D);%0A

remove typedoc command from `gulp watch` because it is so slow