-
Notifications
You must be signed in to change notification settings - Fork 47
/
gulpfile.js
67 lines (55 loc) · 1.42 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
const path = require('path');
const del = require('del');
const gulp = require('gulp');
const log = require('fancy-log');
const coffeelint = require('gulp-coffeelint');
const coffee = require('gulp-coffee');
const karma = require('karma');
const paths = {
src: 'src',
dist: 'lib',
demo: 'docs'
};
function clean() {
return del([`./${paths.dist}`]);
}
function buildCoffee(dest) {
return gulp.src(`./${paths.src}/*.coffee`)
.pipe(coffeelint())
.pipe(coffeelint.reporter())
.pipe(coffee({
bare: false
}).on('error', log))
.pipe(gulp.dest(dest));
}
function build() {
return buildCoffee(`./${paths.dist}/`);
}
function runTests(singleRun, done) {
const localConfig = {
configFile: path.join(__dirname, './karma.conf.coffee'),
singleRun: singleRun,
autoWatch: !singleRun
};
const server = new karma.Server(localConfig, function(failCount) {
done(failCount ? new Error(`Failed ${failCount} tests.`) : null);
});
server.start();
}
function cleanDemo() {
return del([`./${paths.demo}/lib`]);
}
function demo() {
return buildCoffee(`./${paths.demo}/lib/`);
}
gulp.task('test', function(done) {
runTests(true, done);
});
gulp.task('test:auto', function(done) {
runTests(false, done);
});
gulp.task('build', build);
gulp.task('clean', clean);
gulp.task('default', gulp.series(clean, build));
gulp.task('demo:clean', cleanDemo);
gulp.task('demo:build', gulp.series(cleanDemo, demo));