-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.babel.js
79 lines (65 loc) · 2.16 KB
/
gulpfile.babel.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
/* eslint no-console: 0, arrow-body-style: 0 */
const gulp = require('gulp');
const babel = require('gulp-babel');
const clean = require('gulp-clean');
const eslint = require('gulp-eslint');
const mocha = require('gulp-mocha');
const runSequence = require('run-sequence');
const gulpIstanbul = require('gulp-istanbul');
const isparta = require('isparta');
const sourcemaps = require('gulp-sourcemaps');
const gulpWebpack = require('webpack-stream');
const webpackConfig = require('./webpack.config');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
gulp.task('clean', () => {
return gulp.src(['lib', 'dist', 'coverage', 'upload'], { read: false })
.pipe(clean());
});
gulp.task('babel', () => {
return gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('lib'));
});
gulp.task('lint_code', [], () => {
return gulp.src(['src/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('lint_tests', [], () => {
return gulp.src(['test/**/*.js', '!test/dist/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('lint', ['lint_code', 'lint_tests']);
gulp.task('test_client', () => {
return gulp.src(['test/**/*.js'], { read: false })
.pipe(mocha({ reporter: 'spec' }))
.pipe(gulpIstanbul.writeReports({ reporters: ['json', 'lcov', 'text'] }));
});
gulp.task('compile_web', () => {
return gulp.src('src/pubnub-vue.js')
.pipe(gulpWebpack(webpackConfig))
.pipe(gulp.dest('dist'));
});
gulp.task('pre-test', () => {
return gulp.src(['src/**/*.js'])
.pipe(gulpIstanbul({ instrumenter: isparta.Instrumenter, includeAllSources: true }))
.pipe(gulpIstanbul.hookRequire());
});
gulp.task('uglify_web', () => {
return gulp.src('dist/pubnub-vue.js')
.pipe(uglify({ mangle: true, compress: true }))
.pipe(rename('pubnub-vue.min.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('test', (done) => {
runSequence('pre-test', 'test_client', 'lint', done);
});
gulp.task('compile', (done) => {
runSequence('clean', 'babel', 'compile_web', 'uglify_web', done);
});