forked from adamfitzpatrick/tslint-stylish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
83 lines (70 loc) · 2.29 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
(function () {
"use strict";
var del = require("del");
var gulp = require("gulp");
var mocha = require("gulp-mocha");
var tslint = require("gulp-tslint");
var tsc = require("gulp-typescript");
var watch = require("gulp-watch");
var batch = require("gulp-batch");
var debug = require("gulp-debug");
var minimist = require("minimist");
require("gulp-help")(gulp, {
description: "Help listing"
});
var options = minimist(process.argv.slice(2));
function isProd() {
return options._[0] === "prod";
}
var typescriptOptions = {
declarationFiles: false,
noExternalResolve: false,
module: "commonjs"
};
function clean(cb) {
del([
"compiled",
"index.js",
"stylishFormatter.js",
"reporter.js",
"ruleFailure.js"
]);
cb();
}
gulp.task("clean", clean);
function tsCompile() {
return gulp.src("src/**/*.ts")
.pipe(tslint())
.pipe(tslint.report("verbose", {
emitError: isProd()
}))
.pipe(tsc(typescriptOptions))
.js.pipe(gulp.dest("compiled/src"));
}
function specCompile() {
return gulp.src(["specs/**/*.ts", "!specs/fixtures/**/*"])
.pipe(tslint())
.pipe(tslint.report("verbose", {
emitError: isProd()
}))
.pipe(tsc(typescriptOptions))
.js.pipe(gulp.dest("compiled/specs"));
}
gulp.task("compile:src", "Compile source typescript to javascript.", ["clean"], tsCompile);
gulp.task("compile:spec", "Compile typescript specs to javascript.", ["clean"], specCompile);
function unitTests() {
return gulp.src("compiled/specs/*.spec.js")
.pipe(mocha({reporter: "spec"}));
}
gulp.task("default", "Compile source and specs to javascript and run tests.", ["compile:src", "compile:spec"], unitTests);
function prod() {
return gulp.src([
"compiled/src/*.js"
])
.pipe(gulp.dest("./"));
}
gulp.task("prod", "Build for production: fails on error.", ["default"], prod);
gulp.task("watch", function () {
gulp.watch(["src/**/*.ts", "specs/**/*.ts"], ["default"]);
});
}());