-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
84 lines (70 loc) · 1.93 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const gulp = require('gulp'),
nodemon = require('gulp-nodemon'),
plumber = require('gulp-plumber'),
livereload = require('gulp-livereload'),
jshint = require('gulp-jshint'),
sass = require('gulp-sass'),
fs = require('fs-extra');
const exec = require('child_process').exec;
const jsSrc = ['app.js', 'lib/**/*.js', 'app/**/*.js', './public/js/**/*.js'];
// Initialize required directories
gulp.task('init', (done) => {
console.log('Synchronously creating required directories');
fs.ensureDirSync('./public/');
fs.ensureDirSync('./data/');
fs.ensureDirSync('./logs/');
fs.ensureDirSync('./etc/');
fs.ensureDirSync('./resources/');
// Add any other required directories here
// Signal completion
done();
});
// Lint Task
gulp.task('lint', (done) => {
gulp.src(jsSrc)
.pipe(jshint({ esversion: 6, node: true }))
.pipe(jshint.reporter('default', {verbose: true}));
// And also report file annotation counts
exec('resources/counts.sh', (err, stdout, stderr) => {
if (err) console.log("Couldn't run annotation counting script: ", err);
console.log(stdout);
});
// Signal completion
done();
});
gulp.task('sass', (done) => {
gulp.src('./sass/style.scss')
.pipe(plumber())
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./public/css'))
.pipe(livereload());
// Signal completion
done();
});
gulp.task('watch', (done) => {
gulp.watch('./sass/**/*.scss', {usePolling: true}, gulp.series('sass'));
gulp.watch(jsSrc, {usePolling: true}, gulp.series('lint'));
// Signal completion
done();
});
gulp.task('develop', (done) => {
livereload.listen();
nodemon({
script: 'app.js',
ext: 'js njk',
ignore: ['data/', 'dist/']
}).on('restart', () => {
setTimeout( () => {
livereload.changed(__dirname);
}, 500);
});
// Signal completion
done();
});
gulp.task('default', gulp.series(
'init',
'lint',
'sass',
'develop',
'watch'
));