-
Notifications
You must be signed in to change notification settings - Fork 32
/
gulpfile.js
55 lines (44 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
43
44
45
46
47
48
49
50
51
52
53
54
55
var gulp = require('gulp'),
spawn = require('child_process').spawn,
browserSync = require('browser-sync'),
notifier = require('node-notifier');
var Logger = function() {
var logger = function() {
};
var _log = function(message) {
console.log(message);
};
var _notify = function(title, message) {
notifier.notify({
title: title,
message: message
});
};
logger.prototype = {
log : _log,
notify : _notify
};
return logger;
}();
gulp.task('jekyll', function () {
var jekyll = spawn('jekyll', ['build']);
var logger = new Logger();
jekyll.stderr.on('data', function(data) {
logger.log("" + data);
logger.notify('Build Error', data);
});
jekyll.on('exit', function (code) {
var message = code ? 'error' : 'success';
logger.log('Finished Jekyll Build : ' + message);
browserSync.reload();
});
});
gulp.task('serve', function() {
browserSync.init(null, {
server: {baseDir: './_site'}
});
});
gulp.task('watch', function () {
gulp.watch(['_data/**/*.yml', '**/*.html', '**/*.md', '**/*.scss', '**/*.css', '**/*.js', '!_site/**/*', '!node_modules/**/*'], ['jekyll']);
});
gulp.task('default', ['jekyll', 'serve', 'watch']);