forked from davideast/Querybase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
98 lines (86 loc) · 2.26 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
94
95
96
97
98
'use strict';
const gulp = require('gulp');
const del = require('del');
const mocha = require('gulp-mocha');
const runSequence = require('run-sequence');
const istanbul = require('gulp-istanbul');
const firebaseServer = require('./src/tests/firebaseServer');
const uglify = require('gulp-uglify');
const size = require('gulp-size');
const ts = require('gulp-typescript');
const rollup = require('gulp-better-rollup')
const rename = require('gulp-rename');
const tsProject = ts.createProject('tsconfig.json');
const testTsProject = ts.createProject('tsconfig.test.json');
const exit = () => process.exit(0);
gulp.task('clean', () => del(['examples/*.js', 'examples/*.js.map', '!examples/index.js', 'dist', 'es6']));
gulp.task('ts', () => {
const tsResult = tsProject.src()
.pipe(tsProject());
return tsResult.js
.pipe(gulp.dest('./es6'));
});
gulp.task('rollup', () => {
return gulp.src('./es6/entry.js')
.pipe(rollup({
entry: './es6/entry.js',
moduleName: 'querybase'
}, 'umd'))
.pipe(rename('querybase.umd.js'))
.pipe(gulp.dest('./dist'));
});
gulp.task('uglify', () => {
return gulp
.src('./dist/querybase.umd.js')
.pipe(uglify({ mangle: true }))
.pipe(rename('querybase.umd.min.js'))
.pipe(gulp.dest('./dist'));
});
gulp.task('size', () => {
return gulp
.src('./dist/querybase.umd.min.js')
.pipe(size({
showFiles: true,
gzip: true
}));
});
gulp.task('ts-tests', () => {
const tsResult = testTsProject.src()
.pipe(testTsProject());
return tsResult.js
.pipe(gulp.dest('./dist'));
});
gulp.task('pre-test', () => {
return gulp
.src([
'./dist/entry.js',
'./dist/querybase.js',
'./dist/QuerybaseQuery.js',
'./dist/QuerybaseUtils.js',
])
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
gulp.task('test', ['firebaseServer'], () => {
return gulp
.src('./dist/tests/unit/**.spec.js', { read: false })
.pipe(mocha({ reporter: 'spec' }))
.pipe(istanbul.writeReports());
});
gulp.task('firebaseServer', () => {
firebaseServer.initializeApp();
});
gulp.task('default', runSequence(
'clean',
'ts',
'rollup',
'ts-tests',
'pre-test',
'test',
'uglify',
'size',
exit
)
);