-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (67 loc) · 1.55 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
const gulp = require('gulp'),
connect = require('gulp-connect'),
eslint = require('gulp-eslint'),
rename = require('gulp-rename'),
coveralls = require('gulp-coveralls'),
browserify = require('gulp-browserify'),
browserSync = require('browser-sync').create();
gulp.task('scripts', () => {
gulp.src('./spec/InvertedIndex.spec.js')
.pipe(browserify())
.pipe(rename('bundle.js'))
.pipe(gulp.dest('./build'));
});
gulp.task('watch', () => {
gulp.watch('./src/*.js', ['reload']);
gulp.watch('./src/public/css/*.css', ['reload']);
gulp.watch('*.html', ['reload']);
});
gulp.task('test', ['pre-test'], () => (
gulp.src('spec/*.js')
.on('end', () => {
gulp.src('coverage/lcov.info')
.pipe(coveralls());
})
));
gulp.task('serve', ['watch'], () => {
browserSync.init({
server: {
baseDir: './'
}
});
});
gulp.task('lint', () => {
gulp.src(['src/InvertedIndex.js', '!node_modules/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('test-watch', () => {
gulp.watch('spec/*.js', ['test-reload']);
});
gulp.task('test-reload', () => {
gulp.src(['spec/*.js']).pipe(connect.reload());
});
gulp.task('connect', () => {
connect.server({
root: '.',
livereload: true,
port: process.env.PORT || 3000
});
});
gulp.task('reload', () => {
gulp.src(
['*.html',
'src/*.js',
'*.css'
]).pipe(connect.reload());
});
gulp.task('default',
[
'scripts',
'reload',
'test-watch',
'test-reload',
'connect',
'watch'
]);