forked from kobotoolbox/kpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (51 loc) · 1.7 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
// Currently:
// This gulpfile only focuses on building and running tests of js and react code
var gulp = require("gulp"),
browserSync = require("browser-sync"),
browserify = require("browserify"),
source = require("vinyl-source-stream"),
clean = require("gulp-clean"),
mochaPhantomJS = require("gulp-mocha-phantomjs");
gulp.task("browserify", function() {
"use strict";
return browserify({
entries: 'test/index.js',
extensions: ['.js', '.es6', '.coffee'],
require: ['jszip'],
read: false,
})
.ignore('jszip')
.transform("babelify", {
presets: ['es2015', 'react'],
extensions: ['.js', '.es6'],
})
.transform('coffeeify', {
extensions: ['.coffee'],
})
.bundle()
.pipe(source('tests-index-compiled.js'))
.pipe(gulp.dest(__dirname + "/tmp"));
});
gulp.task("clean", function () {
return gulp.src("tmp/tests-index-compiled.js", {read: false})
.pipe(clean());
});
gulp.task("test", function () {
return gulp.src("./test/tests.html").pipe(mochaPhantomJS());
});
gulp.task("browser-sync", function () {
"use strict";
browserSync({
server: {
//serve tests and the root as base dirs
baseDir: ["./test/", "./jsapp/"],
//make tests.html the index file
index: "tests.html"
}
});
});
gulp.task("serve", ["browserify", "browser-sync"], function () {
"use strict";
//when tests.js changes, browserify code and execute tests
gulp.watch(["test/*.js", "test/**/*.js"], ["browserify", "test", "clean"]);
});