-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
66 lines (59 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
/* eslint-env: node */
const gulp = require("gulp");
const browserSync = require("browser-sync");
const browserify = require("browserify");
const source = require("vinyl-source-stream");
const babelify = require("babelify");
const mochaPhantomJS = require("gulp-mocha-phantomjs");
const gutil = require('gulp-util');
const gulpJsdoc2md = require('gulp-jsdoc-to-markdown')
const rename = require('gulp-rename')
gulp.task("browser-sync", function () {
browserSync({
server: {
//serve tests and the root as base dirs
baseDir: ["./test/", "./"],
//make tests.html the index file
index: "index.html"
}
});
});
gulp.task("browserify", function () {
return browserify("./test/tests.js", { debug: true })
.transform([babelify,])
.on("error", function (e) {
console.log(e.message);
this.emit("end");
})
.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", ["browserify"], function () {
return gulp.src("./test/index.html")
.pipe(mochaPhantomJS());
});
//////////////////////////////
// GENERATING DOCUMENTATION //
//////////////////////////////
gulp.task('docs', function () {
return gulp.src('src/*.js')
.pipe(gulpJsdoc2md())
.on('error', function (err) {
gutil.log(gutil.colors.red('jsdoc2md failed'), err.message)
})
.pipe(rename(function (path) {
path.extname = '.md'
}))
.pipe(gulp.dest('api'))
})
gulp.task("serve", ["browserify", "browser-sync", "docs"], function () {
//when tests.js changes, browserify code and execute tests
gulp.watch(["test/tests.js", "src/**/*.js"], ["browserify"]);
gulp.watch(["src/**/*.js"], ["docs"]);
});