forked from stacktracejs/stacktrace-gps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
100 lines (87 loc) · 2.75 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
var concat = require('gulp-concat');
var coveralls = require('gulp-coveralls');
var del = require('del');
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var karma = require('karma');
var path = require('path');
var runSequence = require('run-sequence');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var webpack = require('webpack');
var polyfills = [
'./node_modules/es6-promise/dist/es6-promise.js',
'./polyfills.js'
];
var dependencies = [
'./node_modules/stackframe/dist/stackframe.js',
'./build/bundle.js'
];
var source = 'stacktrace-gps.js';
gulp.task('lint', function() {
return gulp.src(source)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
gulp.task('webpack-source-consumer', function() {
return webpack({
entry: './node_modules/source-map/lib/source-map-consumer.js',
output: {
library: 'SourceMap',
path: path.join(__dirname, 'build'),
name: 'bundle.js'
}
}, function(err) {
if (err) {
throw new Error('webpack', err);
}
});
});
gulp.task('test', ['webpack-source-consumer'], function(done) {
new karma.Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('test-pr', ['dist'], function(done) {
new karma.Server({
configFile: __dirname + '/karma.conf.js',
browsers: ['Firefox', 'ChromeTravis'],
singleRun: true
}, done).start();
});
gulp.task('test-ci', ['dist'], function(done) {
new karma.Server({
configFile: __dirname + '/karma.conf.ci.js',
singleRun: true
}, done).start();
});
gulp.task('copy', function() {
return gulp.src(source)
.pipe(gulp.dest('dist'));
});
gulp.task('dist', ['copy', 'webpack-source-consumer'], function() {
// Build with ES6Promise and other polyfills
gulp.src(polyfills.concat(dependencies.concat(source)))
.pipe(sourcemaps.init())
.pipe(concat(source.replace('.js', '-with-polyfills.min.js')))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'));
return gulp.src(dependencies.concat(source))
.pipe(sourcemaps.init())
.pipe(concat(source.replace('.js', '.min.js')))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'));
});
gulp.task('clean', del.bind(null, ['build', 'coverage', 'dist']));
gulp.task('pr', ['lint', 'test-pr']);
gulp.task('ci', ['lint', 'test-ci'], function() {
gulp.src('./coverage/**/lcov.info')
.pipe(coveralls());
});
gulp.task('default', ['clean'], function(cb) {
runSequence('lint', ['copy', 'dist'], 'test', cb);
});