-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
111 lines (101 loc) · 2.65 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
var gulp = require('gulp'),
pkg = require('./package.json');
var aws = require('gulp-awspublish'),
browserify = require('browserify'),
buffer = require('vinyl-buffer'),
connect = require('gulp-connect'),
compress = require('gulp-yuicompressor'),
eslint = require('gulp-eslint'),
flow = require('gulp-flowtype'),
gutil = require('gulp-util'),
karma = require('karma'),
source = require('vinyl-source-stream'),
sourcemaps = require('gulp-sourcemaps'),
tapeRunner = require('tape-run');
gulp.task('default', ['build', 'connect', 'watch']);
gulp.task('build', function(){
return browserify({
entries: './lib/index.js',
debug: true
})
.bundle()
.pipe(source('keen-core.js'))
.pipe(buffer())
.on('error', gutil.log)
.pipe(gulp.dest('./test'));
});
gulp.task('connect', ['build'], function () {
return connect.server({
root: [ 'test' ],
port: 9003
});
});
gulp.task('lint', function () {
return gulp.src([
'./lib/**/*.js'
])
.pipe(flow({
all: false,
weak: false,
declarations: './declarations',
killFlow: false,
beep: true,
abort: false
}))
.pipe(eslint({
rules: {
'strict': 0
}
}))
// Output results to the console
.pipe(eslint.format())
// Exit process with an error code (1) on error
.pipe(eslint.failAfterError())
// Verify yui-compressor ok-ness
.pipe(compress());
});
gulp.task('watch', ['lint', 'build'], function() {
gulp.watch([
'lib/**/*.js',
'gulpfile.js',
'test/index.js'
], ['build', 'lint']);
});
gulp.task('test', ['test:tape', 'test:karma']);
gulp.task('test:tape', function(){
browserify({
entries: './test/index.js',
debug: true
})
.bundle()
.pipe(tapeRunner())
.on('error', gutil.log)
.on('results', gutil.log)
.pipe(process.stdout)
.pipe(source('bundle.js'))
.pipe(buffer())
// .pipe(compress())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./test'));
});
gulp.task('test:karma', ['build'], function(done) {
new karma.Server({
configFile: __dirname + '/test/karma/index.js',
singleRun: true
}, function(exitCode){
gutil.log('Karma test runner has exited with ' + exitCode);
process.exit(exitCode);
done(exitCode);
}).start();
});
gulp.task('test:sauce', ['build'], function(done){
new karma.Server({
configFile: __dirname + '/test/karma/sauce.js',
singleRun: true
}, function(exitCode){
gutil.log('Saucelabs test runner has exited with ' + exitCode);
process.exit(exitCode);
done(exitCode);
}).start();
});