-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
69 lines (55 loc) · 1.58 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
var gulp = require('gulp')
, nodemon = require('gulp-nodemon')
, jshint = require('gulp-jshint')
, spawn = require('child_process').spawn
, gutil = require('gulp-util');
JS_FILES = ['./lib/**/*.js', './test/**/*.js'];
gulp.task('lint', function () {
gulp.src(JS_FILES)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('handbook', function (e) {
var formats = [
{
ext: "epub",
writer: "epub"
},
{
ext: "pdf",
writer: "latex"
},
{
ext: "docx",
writer: "docx"
}];
formats.forEach(function (f) {
var child = spawn("pandoc", ["--toc", "-f", "markdown", "--latex-engine=xelatex", "-t", f.writer, "-o", "handbook." + f.ext, "handbook.md"], {cwd: process.cwd() + "/public"}),
stdout = '',
stderr = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', function (data) {
stdout += data;
gutil.log(data);
});
child.stderr.setEncoding('utf8');
child.stderr.on('data', function (data) {
stderr += data;
gutil.log(gutil.colors.red(data));
gutil.beep();
});
child.on('close', function (code) {
gutil.log("Done with exit code", code);
gutil.log("You access complete stdout and stderr from here"); // stdout, stderr
});
});
});
gulp.task('dev', function () {
gulp.watch('public/handbook.md', ['handbook']);
gutil.log("Website running at: http://localhost:9090/");
nodemon({script: 'server.js', ext: 'js'})
.on('change', ['lint'])
.on('restart', function () {
console.log('restarted!')
});
});