-
Notifications
You must be signed in to change notification settings - Fork 17
/
gulpfile.js
executable file
·74 lines (64 loc) · 2.15 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
(function() {
"use strict";
var gulp = require("gulp");
var eslint = require("gulp-eslint");
var uglify = require("gulp-uglify");
var mocha = require("gulp-spawn-mocha");
var rename = require("gulp-rename");
var Server = require("karma").Server;
var path = require("path");
var fs = require("fs");
var gls = require("gulp-live-server");
gulp.task("lint", function() {
return gulp.src(["*.js", "src/*.js", "test/*.js"])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task("lint:build", function() {
return gulp.src(["*.js", "src/*.js", "test/*.js"])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.format("checkstyle", fs.createWriteStream("eslint.xml")));
});
gulp.task("compress", function() {
return gulp.src("src/*.js")
.pipe(rename({
suffix: ".min"
}))
.pipe(uglify({ mangle: true }))
.pipe(gulp.dest("dist"));
});
gulp.task("mocha", function() {
return gulp.src("test/test-*.js",
{
read: false
})
.pipe(mocha());
});
gulp.task("mocha-tap", gulp.series("mocha", function() {
return gulp.src("test/test-*.js",
{
read: false
})
.pipe(mocha({
reporter: "tap",
output: "./test/mocha.tap"
}));
}));
gulp.task("karma", gulp.series("mocha", "mocha-tap", function(done) {
new Server({
configFile: path.join(__dirname, "karma.config.js"),
singleRun: true
}, done).start();
}));
gulp.task("server", function() {
var server = gls.new("./test/server.js");
return server.start();
});
gulp.task("test", gulp.series("mocha", "mocha-tap", "karma"));
gulp.task("test:debug", gulp.series("server"));
gulp.task("default", gulp.series("lint", "lint:build", "compress", "test"));
gulp.task("all", gulp.series("default"));
gulp.task("travis", gulp.series("default"));
}());