/
gulpfile.js
95 lines (81 loc) · 2.96 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
var gulp = require('gulp');
var tang = require('./');
var sourcemaps = require('gulp-sourcemaps');
var karma = require('karma').server;
var testUtils = require('angular-test-utils-test-utils');
// --------------------------- //
// use gulp source-map support //
// --------------------------- //
gulp.task('instrument-files-gulp-source-maps', function (){
return gulp.src('./fixtures/*.js')
.pipe(sourcemaps.init())
.pipe(tang())
.pipe(sourcemaps.write())
.pipe(gulp.dest('build/gulp-source-maps'))
});
gulp.task('karma-gulp-source-maps', ['instrument-files-gulp-source-maps'], function(cb) {
karma.start(karmaConf('gulp-source-maps'), cb)
});
gulp.task('karma-gulp-source-maps-error', ['instrument-files-gulp-source-maps'], function(cb) {
karma.start(karmaConf('gulp-source-maps', true), testUtils.validateErrorMapping(
'./build/gulp-source-maps-error-report.xml',
/math-test-error.js:28:(5|11)/, //Browsers differ- they measure from either start of `throw` or start of `new Error`
cb
));
});
// -------------------------------- //
// use internal source-map handling //
// -------------------------------- //
gulp.task('instrument-files-internal-source-maps', function() {
return gulp.src('./fixtures/*.js')
.pipe(tang({
sourceMap:true
}))
.pipe(gulp.dest('build/internal-source-maps'))
});
gulp.task('karma-internal-source-maps', ['instrument-files-internal-source-maps'], function(cb) {
karma.start(karmaConf('internal-source-maps'), cb);
});
gulp.task('karma-internal-source-maps-error', ['instrument-files-internal-source-maps'], function(cb) {
karma.start(karmaConf('internal-source-maps', true), testUtils.validateErrorMapping(
'./build/internal-source-maps-error-report.xml',
/math-test-error.js:28:(5|11)/, //Browsers differ- they measure from either start of `throw` or start of `new Error`
cb
));
});
// --------------------------------- //
// production build / no source-maps //
// --------------------------------- //
gulp.task('instrument-files-no-source-maps', function() {
return gulp.src('./fixtures/*.js')
.pipe(tang())
.pipe(gulp.dest('build/no-source-maps'))
});
gulp.task('validate-no-source-maps', ['instrument-files-no-source-maps'], function() {
['./build/no-source-maps/math.js',
'./build/no-source-maps/math-test.js',
'./build/no-source-maps/math-test-error.js'].forEach(testUtils.validateNoSourceMap);
});
gulp.task('success', [
'karma-gulp-source-maps',
'karma-gulp-source-maps-error',
'karma-internal-source-maps',
'karma-internal-source-maps-error',
'validate-no-source-maps'
], testUtils.success);
gulp.task('default',['success']);
function karmaConf(prefix, error){
return testUtils.karmaTemplate(prefix, error,
[
'node_modules/angular/angular.js',
'node_modules/angular-mocks/angular-mocks.js',
'build/{prefix}/math.js',
'build/{prefix}/math-test{error}.js'
],
{
preprocessors: {
'**/*.js':'sourcemap'
}
}
)
}