-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
59 lines (53 loc) · 1.21 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
/**
* Web Service Build System
*/
const gulp = require('gulp');
const pump = require('pump');
const fs = require('fs');
const del = require('del');
const rename = require('gulp-rename');
const replace = require('gulp-replace');
const markdown = require('gulp-markdown');
/**
* Converts Markdown help into the HTML format
*/
gulp.task('parse-doc', function (cb) {
pump(
gulp.src('doc/asset/help.md', {base: './'}),
markdown(),
gulp.dest('.'),
cb
)
});
/**
* Wraps the help content in the HTML container
*/
gulp.task('build-doc', function (cb) {
pump(
gulp.src('doc/asset/container.html', {base: './'}),
replace('{{api}}', () => {
return fs.readFileSync('doc/asset/help.html');
}),
replace(' id="-"', ''), // remove extra element IDs generated by marked
rename('doc/index.html'),
gulp.dest('.'),
cb
)
});
/**
* Removes extra files
*/
gulp.task('cleanup', function (cb) {
del(['doc/asset/help.html']);
cb();
});
/**
* Executes all tasks one after the other
*/
gulp.task('default', gulp.series('parse-doc', 'build-doc', 'cleanup'));
/**
* Builds on changes in files
*/
gulp.task('watch', () => {
gulp.watch(['samples/**', 'doc/**'], gulp.series('default'));
});