-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
54 lines (48 loc) · 1.32 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
'use strict'
const coffee = require('gulp-coffee')
const gulp = require('gulp')
gulp.task('clean', (done) => {
const del = require('del')
del.sync([ 'dist/*' ])
done()
})
gulp.task('build:server', () => {
const uglify = require('gulp-uglify-es').default
const gutil = require('gulp-util')
const rename = require('gulp-rename')
return gulp.src('src/**/*.coffee')
.pipe(coffee({ bare: true }))
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist/'))
})
gulp.task('build:minify', ['build:server'], () => {
return gulp.src('dist/index.js')
.pipe(gulp.dest('dist/'))
})
gulp.task('test:unit', [], () => {
require('coffee-script/register');
const mocha = require('gulp-mocha')
return gulp.src(['test/**/*.coffee', '!test/*.coffee'], { read: false })
.pipe(mocha())
.once('error', (err) => {
if (err.stack) {
console.log(err.stack);
} else {
console.log(err);
}
process.exit(1);
})
.once('end', () => {
process.exit();
})
})
gulp.task('watch:server', [ 'build:server' ], () => {
gulp.watch('src/**/*.coffee', { interval: 500 }, [ 'build:server' ])
})
gulp.task('build', [ 'clean', 'build:server' ])
gulp.task('test', [ 'test:unit' ])
gulp.task('watch', [ 'watch:server' ])
gulp.task('default', [ 'build', 'watch' ])