-
Notifications
You must be signed in to change notification settings - Fork 21
/
gulpfile.js
93 lines (81 loc) · 2.22 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
'use strict';
var browserify = require('browserify');
var gulp = require('gulp');
var mocha = require('gulp-mocha');
var mochaPhantom = require('gulp-mocha-phantomjs');
var istanbul = require('gulp-istanbul');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
gulp.task('browserify', function () {
// set up the browserify instance on a task basis
var b = browserify(['./lib/bluebird-retry.js'], {
bundleExternal: false,
standalone: 'bluebirdRetry',
debug: true
});
return b.bundle()
.pipe(source('bluebird-retry.js'))
.pipe(buffer())
.pipe(gulp.dest('./browser/'));
});
gulp.task('browserify-test', function () {
// set up the browserify instance on a task basis
var b = browserify({
entries: 'test/bluebird-retry.spec.js',
bundleExternal: true,
debug: true
});
return b.bundle()
.pipe(source('test/bluebird-retry.spec.js'))
.pipe(buffer())
.pipe(gulp.dest('./browser'));
});
gulp.task('build', ['browserify', 'browserify-test']);
gulp.task('instrument', function () {
return gulp.src([
'lib/*.js'
])
.pipe(istanbul({
includeUntested: true
}))
.pipe(istanbul.hookRequire());
});
function gulp_test() {
return gulp.src('test/*.spec.js')
.pipe(mocha({
log: true,
timeout: 10000,
slow: 3000,
reporter: 'spec',
ui: 'bdd',
ignoreLeaks: true,
globals: ['should']
}));
}
gulp.task('test-node', function() {
return gulp_test();
});
gulp.task('test-phantom', function() {
return gulp.src('browser/test/index.html')
.pipe(mochaPhantom({
reporter: 'spec',
mocha: {
colors: true
}
}));
});
gulp.task('test-coverage', ['instrument'], function() {
return gulp_test()
.pipe(istanbul.writeReports())
.pipe(istanbul.enforceThresholds({
thresholds: {
global: {
statements: 100,
branches: 100,
functions: 100,
lines: 100
}
}
}));
});
gulp.task('test', ['test-coverage', 'test-phantom']);