-
Notifications
You must be signed in to change notification settings - Fork 19
/
gulpfile.js
59 lines (52 loc) · 1.78 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
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
mocha = require('gulp-mocha'),
browserify = require('browserify'),
Server = require('karma').Server,
uglify = require('gulp-uglify'),
rimraf = require('rimraf'),
source = require('vinyl-source-stream'),
rename = require('gulp-rename'),
streamify = require('gulp-streamify');
gulp.task('lint', function() {
return gulp.src(['./lib/*.js', './test/*.js', './examples/*.js'])
.pipe(jshint({node: true, browser: true, validthis: true,
eqnull: true, globals: {Promise: true}}))
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('test-node', ['lint'], function () {
return gulp.src('test/live-find.spec.js', {read: false})
.pipe(mocha({timeout: 5000}));
});
gulp.task('clean', ['test-node'], function (cb) {
rimraf('./dist', cb);
});
gulp.task('build-browser', ['clean'], function() {
return browserify('./lib/index.js')
.bundle()
.pipe(source('pouchdb.live-find.js'))
.pipe(gulp.dest('./dist/'))
.pipe(rename('pouchdb.live-find.min.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest('./dist/'));
});
gulp.task('build-browser-test', ['build-browser'], function() {
return browserify('./test/live-find.spec.js')
.exclude('pouchdb')
.exclude('pouchdb-find')
.exclude('memdown')
.exclude('chai')
.exclude('./lib/index.js')
.bundle()
.pipe(source('live-find.browser.spec.js'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('test-browser', ['build-browser-test'], function (done) {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('default', ['test-browser','build-browser-test', 'build-browser', 'clean', 'test-node', 'lint']);