forked from stellar/js-stellar-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
155 lines (137 loc) · 3.58 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
'use strict';
var gulp = require('gulp');
var isparta = require('isparta');
var plugins = require('gulp-load-plugins')();
var coveralls = require('@kollavarsham/gulp-coveralls');
var clear = require('clear');
var webpackConfigBrowser = require('./webpack.config.browser.js');
var webpack = require('webpack-stream');
var del = require('del');
gulp.task('lint:src', function lintSrc() {
return gulp
.src(['src/**/*.js'])
.pipe(plugins.eslint())
.pipe(plugins.eslint.format())
.pipe(plugins.eslint.failAfterError());
});
// Lint our test code
gulp.task('lint:test', function lintTest() {
return gulp
.src(['test/unit/**/*.js'])
.pipe(plugins.eslint())
.pipe(plugins.eslint.format())
.pipe(plugins.eslint.failAfterError());
});
gulp.task(
'build:node',
gulp.series('lint:src', function buildNode() {
return gulp
.src('src/**/*.js')
.pipe(plugins.babel())
.pipe(gulp.dest('lib'));
})
);
gulp.task(
'build:browser',
gulp.series('lint:src', function buildNode() {
return gulp
.src('src/browser.js')
.pipe(webpack(webpackConfigBrowser))
.pipe(plugins.rename('stellar-base.js'))
.pipe(gulp.dest('dist'))
.pipe(
plugins.uglify({
output: {
ascii_only: true
}
})
)
.pipe(plugins.rename('stellar-base.min.js'))
.pipe(gulp.dest('dist'));
})
);
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:node',
gulp.series('build:node', 'test:init-istanbul', function testNode() {
return gulp
.src(['test/test-helper.js', 'test/unit/**/*.js'])
.pipe(
plugins.mocha({
reporter: ['dot']
})
)
.pipe(plugins.istanbul.writeReports());
})
);
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:watch', function() {
return gulp.watch(['src/**/*', 'test/unit/**/*.js'], gulp.series(['clear-screen', 'test:node']));
});
gulp.task(
'test:sauce',
gulp.series('build:browser', 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', function clean() {
return del(['dist/', 'lib/']);
});
gulp.task('build', gulp.series('clean', 'build:node', 'build:browser'));
gulp.task('test', gulp.series('clean', 'test:node', 'test:browser'));
gulp.task('default', gulp.series('build'));
gulp.task(
'watch',
gulp.series('build', function watch() {
gulp.watch('src/**/*', ['clear-screen', 'build']);
})
);
gulp.task('submit-coverage', function submitCoverage() {
return gulp.src('./coverage/**/lcov.info').pipe(coveralls());
});