forked from stellar/js-stellar-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
194 lines (174 loc) · 4.32 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
'use strict';
var cp = require('child_process');
var coveralls = require('@kollavarsham/gulp-coveralls');
var gulp = require('gulp');
var isparta = require('isparta');
var plugins = require('gulp-load-plugins')();
var webpack = require('webpack');
var webpackStream = require('webpack-stream');
var webpackConfigBrowser = require('./webpack.config.browser.js');
var clear = require('clear');
var plumber = require('gulp-plumber');
var del = require('del');
gulp.task('lint:src', function lintSrc() {
return gulp
.src(['src/**/*.ts'])
.pipe(plumber())
.pipe(plugins.tslint({ formatter: "verbose" }))
.pipe(plugins.tslint.report());
});
// Lint our test code
gulp.task('lint:test', function lintTest() {
return gulp
.src(['test/unit/**/*.js', 'gulpfile.js'])
.pipe(plumber())
.pipe(plugins.eslint())
.pipe(plugins.eslint.format())
.pipe(plugins.eslint.failAfterError());
});
gulp.task('clean', function clean() {
return del(['dist/', 'lib/']);
});
gulp.task(
'build:node',
gulp.series(
function buildNode(done) {
// TODO: Gulp-ify using `gulp-typescript`.
try {
cp.execSync(`npx tsc`, {stdio: 'inherit'})
done()
} catch(err) {
done(err)
}
}
)
);
gulp.task(
'build:docs',
gulp.series(
function buildNode(done) {
// TODO: Gulp-ify using `gulp-typescript`.
try {
cp.execSync(`npx tsc --removeComments false --outDir libdocs --target es6 --module esnext`, {stdio: 'inherit'})
done()
} catch(err) {
done(err)
}
}
)
);
gulp.task(
'build:browser',
gulp.parallel(
'lint:src',
function buildBrowser() {
return gulp
.src('src/browser.ts')
.pipe(
webpackStream(webpackConfigBrowser), webpack
)
.pipe(gulp.dest('dist'))
}
)
);
gulp.task('test:watch', function() {
return gulp.watch(['src/**/*', 'test/unit/**/*.js'], gulp.series(['clear-screen', 'test:unit']));
})
gulp.task(
'test:unit',
gulp.series('build:node', function testUnit() {
return gulp.src(['test/test-nodejs.js', 'test/unit/**/*.js']).pipe(
plugins.mocha({
reporter: ['spec']
})
);
})
);
gulp.task(
'test:browser',
gulp.series('build:browser', function testBrowser(done) {
var Server = require('karma').Server;
var server = new Server(
{ configFile: __dirname + '/karma.conf.js' },
(exitCode) => {
if (exitCode !== 0) {
done(new Error(`Bad exit code ${exitCode}`));
} else {
done();
}
}
);
server.start();
})
);
gulp.task(
'test:sauce',
gulp.series(gulp.parallel('build:browser', 'build:node'), function testSauce(done) {
var Server = require('karma').Server;
var server = new Server(
{ configFile: __dirname + '/karma-sauce.conf.js' },
(exitCode) => {
if (exitCode !== 0) {
done(new Error(`Bad exit code ${exitCode}`));
} else {
done();
}
}
);
server.start();
})
);
gulp.task('clear-screen', function clearScreen(cb) {
clear();
cb();
});
gulp.task('clean-coverage', function cleanCoverage() {
return del(['coverage']);
});
gulp.task(
'test:init-istanbul',
gulp.series('clean-coverage', function testInitIstanbul() {
return gulp
.src(['src/**/*.js'])
.pipe(
plugins.istanbul({
instrumenter: isparta.Instrumenter
})
)
.pipe(plugins.istanbul.hookRequire());
})
);
gulp.task(
'test:integration',
gulp.series('build:node', 'test:init-istanbul', function testIntegration() {
return gulp
.src([
'test/test-nodejs.js',
'test/unit/**/*.js',
'test/integration/**/*.js'
])
.pipe(
plugins.mocha({
reporter: ['spec']
})
)
.pipe(plugins.istanbul.writeReports());
})
);
gulp.task('submit-coverage', function submitCoverage() {
return gulp.src('./coverage/**/lcov.info').pipe(coveralls());
});
gulp.task('build', gulp.series('clean', 'build:node', 'build:browser'));
gulp.task(
'test',
gulp.series('clean', 'test:unit', 'test:browser', function test(done) {
done();
})
);
gulp.task(
'watch',
gulp.series('build', function watch() {
return gulp.watch('src/**/*', gulp.series(['clear-screen', 'build']));
})
);
gulp.task('default', gulp.series('build'));