This repository has been archived by the owner on Nov 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 231
/
gulpfile.js
117 lines (98 loc) · 2.83 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
require('coffee-script/register');
const gulp = require('gulp'),
istanbul = require('gulp-istanbul'),
umd = require('gulp-umd'),
path = require('path'),
concat = require('gulp-concat'),
insert = require('gulp-insert'),
mocha = require('gulp-mocha'),
babel = require('gulp-babel'),
replace = require('gulp-replace'),
uglify = require('gulp-uglify'),
runSequence = require('run-sequence'),
argv = require('yargs').argv;
const onlyTest = argv.onlyTest || argv.limitTest;
const SQUEL_VERSION = require('./package.json').version;
gulp.task('build-basic', function() {
return gulp.src([
'./src/core.js',
])
.pipe( concat('squel-basic.js') )
.pipe( replace(/<<VERSION_STRING>>/i, SQUEL_VERSION) )
.pipe( babel({
presets: ['env']
}) )
.pipe( umd({
exports: function (file) {
return 'squel';
},
namespace: function(file) {
return 'squel';
}
}))
.pipe( gulp.dest('./dist') )
.pipe( uglify() )
.pipe( insert.prepend('/*! squel | https://github.com/hiddentao/squel | BSD license */') )
.pipe( concat('squel-basic.min.js') )
.pipe( gulp.dest('./dist') )
});
gulp.task('build-full', function() {
return gulp.src([
'./src/core.js',
'./src/mssql.js',
'./src/mysql.js',
'./src/postgres.js',
])
.pipe( concat('squel.js') )
.pipe( replace(/<<VERSION_STRING>>/i, SQUEL_VERSION) )
.pipe( babel({
presets: ['env']
}) )
.pipe( umd({
exports: function (file) {
return 'squel';
},
namespace: function(file) {
return 'squel';
}
}))
.pipe( gulp.dest('./dist') )
.pipe( uglify() )
.pipe( insert.prepend('/*! squel | https://github.com/hiddentao/squel | BSD license */') )
.pipe( concat('squel.min.js') )
.pipe( gulp.dest('./dist') )
});
gulp.task('build', ['build-basic', 'build-full']);
gulp.task('pre-test', function () {
return gulp.src(['dist/*.js'])
.pipe(istanbul())
.pipe(istanbul.hookRequire());
});
gulp.task('test', ['pre-test'], function () {
return gulp.src(onlyTest || [
'./test/baseclasses.test.coffee',
'./test/blocks.test.coffee',
'./test/case.test.coffee',
'./test/custom.test.coffee',
'./test/delete.test.coffee',
'./test/expressions.test.coffee',
'./test/insert.test.coffee',
'./test/select.test.coffee',
'./test/update.test.coffee',
'./test/mssql.test.coffee',
'./test/mysql.test.coffee',
'./test/postgres.test.coffee',
], { read: false })
.pipe(mocha({
ui: 'exports',
reporter: 'spec',
}))
.pipe(istanbul.writeReports({
dir: './test-coverage',
}))
// .pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }))
;
});
gulp.task('default', function(cb) {
runSequence(['build'], 'test', cb);
});