This repository has been archived by the owner on Aug 14, 2022. It is now read-only.
forked from tobilg/mesos-framework-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
83 lines (63 loc) · 1.9 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
"use strict";
var gulp = require("gulp");
var runSequence = require("run-sequence");
var istanbul = require("gulp-istanbul");
var mocha = require("gulp-mocha");
var chalk = require("chalk");
var rimraf = require("rimraf");
var chai = require("chai");
global.expect = chai.expect;
var paths = {
libJsFiles: "./lib/*.js",
testFiles: "./tests/**/*.js",
gulpfile: "./gulpfile.js"
};
gulp.task("dev", ["watch", "validate"]);
gulp.task("watch", function () {
gulp.watch([
paths.libJsFiles,
paths.testFiles,
paths.gulpfile
], [
"validate"
]);
});
gulp.task("validate", function (done) {
runSequence("test", done);
});
gulp.task("test", ["clean"], function (done) {
var coverageVariable = "$$cov_" + new Date().getTime() + "$$";
gulp.src(paths.libJsFiles)
.pipe(istanbul({
coverageVariable: coverageVariable
}))
.pipe(istanbul.hookRequire())
.on("finish", function () {
gulp.src(paths.testFiles)
.pipe(mocha())
.on("error", function (err) {
console.error(String(err));
console.error(chalk.bold.bgRed(" TESTS FAILED "));
done(new Error(" TESTS FAILED "));
})
.pipe(istanbul.writeReports({
reporters: ["lcov"],
coverageVariable: coverageVariable
}))
.on("end", done);
});
});
gulp.task("test-without-coverage", function () {
return gulp.src(paths.testFiles)
.pipe(mocha())
.on("error", function () {
console.log(chalk.bold.bgRed(" TESTS FAILED "));
});
});
gulp.task("clean", ["clean-coverage"]);
gulp.task("clean-coverage", function (done) {
rimraf("./coverage", done);
});
gulp.task("ci", function (done) {
runSequence("test-without-coverage", done);
});