-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
49 lines (42 loc) · 1.44 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
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');
var jshintConfig = {node: true, browser: true, mocha: true, eqnull: true,
globals: {Promise: true, chai: true}};
gulp.task('lint', function() {
return gulp.src(['./*.js', './test/*.js'])
.pipe(jshint(jshintConfig))
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('test-node', ['lint'], function () {
return gulp.src('test/*.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('pouch-mirror.js'))
.pipe(gulp.dest('./dist/'))
.pipe(rename('pouch-mirror.min.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest('./dist/'));
});
gulp.task('test-browser', ['build-browser'], function (done) {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('default', ['test-browser', 'build-browser', 'clean', 'test-node', 'lint']);