This repository has been archived by the owner on Apr 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
139 lines (128 loc) · 3.65 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var rimraf = require('gulp-rimraf');
var merge = require('gulp-merge');
var browserify = require('browserify');
var tsify = require('tsify');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var KarmaServer = require('karma').Server;
function karma(options) {
return new Promise(function(resolve, reject) {
new KarmaServer(options, resolve).start();
});
}
gulp.task('clean', function() {
return gulp
.src('dist')
.pipe(rimraf());
});
gulp.task('build', function () {
var bundle = browserify({
basedir: '.',
debug: true,
entries: ['src/decl.ts'],
cache: {},
packageCache: {}
})
.plugin(tsify)
.bundle();
var debug = bundle
.pipe(source('decl.js'))
.pipe(gulp.dest('dist'));
var min = bundle
.pipe(source('decl.min.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'));
return merge(debug, min);
});
gulp.task('test', function () {
return karma({
configFile: __dirname + '/karma.conf.js',
singleRun: true
});
});
gulp.task('tdd', function () {
return karma({
configFile: __dirname + '/karma.conf.js',
singleRun: false
});
});
gulp.task('ci', function() {
return Promise.resolve()
.then(function() {
return karma({
configFile: __dirname + '/karma.conf.js',
singleRun: true
});
})
.then(function() {
var customLaunchers = {
sl_chrome: {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'Linux'
},
sl_firefox: {
base: 'SauceLabs',
browserName: 'firefox',
platform: 'Linux'
},
sl_mac_safari: {
base: 'SauceLabs',
browserName: 'safari',
platform: 'OS X 10.10'
},
sl_edge: {
base: 'SauceLabs',
browserName: 'MicrosoftEdge',
platform: 'Windows 10'
},
sl_ie_11: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 8.1',
version: '11'
},
sl_ios_safari_9: {
base: 'SauceLabs',
browserName: 'iphone',
version: '9.3'
},
sl_ios_safari_10: {
base: 'SauceLabs',
browserName: 'iphone',
version: '10.3'
},
sl_android_5_1: {
base: 'SauceLabs',
browserName: 'android',
version: '5.1'
},
sl_android_6_0: {
base: 'SauceLabs',
browserName: 'android',
version: '6.0'
}
};
return karma({
configFile: __dirname + '/karma.conf.js',
singleRun: true,
concurrency: 5,
reporters: ['mocha', 'saucelabs'],
browsers: Object.keys(customLaunchers),
customLaunchers: customLaunchers,
sauceLabs: {
testName: 'Decl tests',
build: process.env.TRAVIS_BUILD_NUMBER || process.env.SAUCE_BUILD_ID || Date.now()
},
captureTimeout: 300000,
browserNoActivityTimeout: 300000
});
});
});
gulp.task('default', ['test', 'build']);