-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
42 lines (38 loc) · 1.2 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
var gulp = require("gulp"),
browserSync = require("browser-sync"),
browserify = require("browserify"),
source = require("vinyl-source-stream"),
mochaPhantomJS = require("gulp-mocha-phantomjs");
gulp.task("browser-sync", function () {
"use strict";
browserSync({
server: {
//serve tests and the root as base dirs
baseDir: ["./test/", "./"],
//make tests.html the index file
index: "tests.html"
}
});
});
gulp.task("browserify", function() {
"use strict";
return browserify("./test/tests.js")
.bundle()
.on("error", function (err) {
console.log(err.toString());
this.emit("end");
})
.pipe(source("tests-browserify.js"))
.pipe(gulp.dest("test/"))
.pipe(browserSync.reload({stream:true}));
});
gulp.task("test", function () {
"use strict";
return gulp.src("./test/tests.html")
.pipe(mochaPhantomJS());
});
gulp.task("serve", ["browserify", "browser-sync"], function () {
"use strict";
//when tests.js changes, browserify code and execute tests
gulp.watch(["test/tests.js", "src/text-changer.js"], ["browserify", "test"]);
});