-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
82 lines (70 loc) · 2.17 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
var gulp = require("gulp"),
uglify = require("gulp-uglify"),
jshint = require("gulp-jshint"),
imagemin = require("gulp-imagemin"),
insert = require("gulp-file-insert"),
runSequence = require("run-sequence"),
karma = require("gulp-karma"),
fs = require("fs"),
testFiles = [
"src/js/source.js",
"test/unit/**/*.spec.js"
];
gulp.task("uglify", function() {
return gulp.src(__dirname + "/src/js/piwik.js")
.pipe(insert({
"/* source.js */": "src/js/source.js"
}))
.pipe(uglify())
.pipe(gulp.dest(__dirname + "/public/javascripts"));
});
gulp.task("image-min", function() {
return gulp.src(__dirname + "/src/img/**/*")
.pipe(imagemin())
.pipe(gulp.dest(__dirname + "/public/images"));
});
gulp.task("hint:fail", function() {
return gulp.src(__dirname + "/src/js/source.js")
.pipe(jshint())
.pipe(jshint.reporter("jshint-stylish"))
.pipe(jshint.reporter("fail"))
});
gulp.task("hint", function() {
return gulp.src(__dirname + "/src/js/source.js")
.pipe(jshint())
.pipe(jshint.reporter("jshint-stylish"));
});
gulp.task("test", ["hint:fail"], function() {
return gulp.src(testFiles)
.pipe(karma({
configFile: "karma.conf.js",
action: "run"
}))
.on("error", function(err) {
// Make sure failed tests cause gulp to exit non-zero
throw err;
});
});
gulp.task("test:ci", ["hint:fail"], function() {
return gulp.src(testFiles)
.pipe(karma({
configFile: "karma.conf-ci.js",
action: "run"
}))
.on("error", function(err) {
// Make sure failed tests cause gulp to exit non-zero
throw err;
});
});
gulp.task("build", function() {
return runSequence("test", ["image-min", "uglify"]);
});
gulp.task("default", function() {
gulp.watch(__dirname + "/src/js/**/*.js", ["hint", "uglify"]);
gulp.watch(__dirname + "/src/img/**/*.js", ["image-min"]);
gulp.src(testFiles)
.pipe(karma({
configFile: "karma.conf.js",
action: "watch"
}));
});