-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
92 lines (76 loc) · 2.28 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
'use strict';
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var runSequence = require('run-sequence');
gulp.task('default', ['build']);
gulp.task('lint:src', function() {
return gulp.src(['src/**/*.js'])
.pipe(plugins.plumber())
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('jshint-stylish'))
.pipe(plugins.jshint.reporter('fail'));
});
// Lint our test code
gulp.task('lint:test', function() {
return gulp.src(['test/unit/**/*.js'])
.pipe(plugins.plumber())
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('jshint-stylish'))
.pipe(plugins.jshint.reporter('fail'));
});
gulp.task('build', function(done) {
runSequence('clean', 'build:node', 'build:browser', done);
});
gulp.task('test', function(done) {
runSequence('clean', 'test:node', 'test:browser', done);
});
gulp.task('hooks:precommit', ['build'], function() {
return gulp.src(['dist/*', 'lib/*'])
.pipe(plugins.git.add());
});
gulp.task('build:node', ['lint:src'], function() {
return gulp.src('src/**/*.js')
.pipe(plugins.babel())
.pipe(gulp.dest('lib'));
});
gulp.task('build:browser', ['lint:src'], function() {
return gulp.src('src/browser.js')
.pipe(plugins.webpack({
output: { library: 'XDR' },
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'}
]
}
}))
.pipe(plugins.rename('xdr.js'))
.pipe(gulp.dest('dist'))
.pipe(plugins.uglify())
.pipe(plugins.rename('xdr.min.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('test:node', function() {
require("babel/register", {
ignore: /node_modules/
});
return gulp.src(["test/setup/node.js", "test/unit/**/*.js"])
.pipe(plugins.mocha({
reporter: ['dot']
}));
});
gulp.task('test:browser', ["build:browser"], function (done) {
var karma = require('karma').server;
karma.start({ configFile: __dirname + '/karma.conf.js' }, done);
});
gulp.task('clean', function () {
return gulp.src('dist', { read: false })
.pipe(plugins.rimraf());
});
gulp.task('watch', ['build'], function() {
gulp.watch('lib/**/*', ['build']);
});
gulp.task('submit-coverage', function(cb) {
return gulp
.src("./coverage/**/lcov.info")
.pipe(plugins.coveralls());
});