9
9
10
10
var gulp = require ( 'gulp' ) ;
11
11
var rollup = require ( 'gulp-rollup' ) ;
12
- var rename = require ( " gulp-rename" ) ;
12
+ var rename = require ( ' gulp-rename' ) ;
13
13
var uglify = require ( 'gulp-uglify' ) ;
14
14
var pump = require ( 'pump' ) ;
15
15
var path = require ( 'path' ) ;
@@ -21,28 +21,36 @@ function generateScript(inFile, outFile, minify, callback) {
21
21
var parts = [
22
22
gulp . src ( './build-esm/lib/**/*.js' )
23
23
. pipe ( rollup ( {
24
- entry : inFile ,
25
- format : 'umd' ,
26
- onwarn : function ( warning ) {
24
+ input : inFile ,
25
+ onwarn : function ( warning ) {
27
26
// https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
28
27
if ( warning . code === 'THIS_IS_UNDEFINED' ) {
29
28
return ;
30
29
}
31
30
console . error ( warning . message ) ;
32
31
} ,
33
- banner : '/**\n'
34
- + '* @license\n'
35
- + '* Copyright Google Inc. All Rights Reserved.\n'
36
- + '*\n'
37
- + '* Use of this source code is governed by an MIT-style license that can be\n'
38
- + '* found in the LICENSE file at https://angular.io/license\n'
39
- + '*/' ,
40
- globals : {
41
- 'rxjs/Observable' : 'Rx' ,
42
- 'rxjs/Subscriber' : 'Rx' ,
43
- 'rxjs/Subscription' : 'Rx' ,
44
- 'rxjs/scheduler/asap' : 'Rx.Scheduler' ,
45
- 'rxjs/symbol/rxSubscriber' : 'Rx.Symbol'
32
+ output : {
33
+ format : 'umd' ,
34
+ banner : '/**\n' +
35
+ '* @license\n' +
36
+ '* Copyright Google Inc. All Rights Reserved.\n' +
37
+ '*\n' +
38
+ '* Use of this source code is governed by an MIT-style license that can be\n' +
39
+ '* found in the LICENSE file at https://angular.io/license\n' +
40
+ '*/' ,
41
+ globals : {
42
+ 'rxjs/Observable' : 'Rx' ,
43
+ 'rxjs/Subscriber' : 'Rx' ,
44
+ 'rxjs/Subscription' : 'Rx' ,
45
+ 'rxjs/scheduler/asap' : 'Rx.Scheduler' ,
46
+ 'rxjs/symbol/rxSubscriber' : 'Rx.Symbol'
47
+ }
48
+ } ,
49
+ external : id => {
50
+ if ( / b u i l d - e s m / . test ( id ) ) {
51
+ return false ;
52
+ }
53
+ return / r x j s / . test ( id ) ;
46
54
}
47
55
} ) )
48
56
. pipe ( rename ( outFile ) ) ,
@@ -56,21 +64,22 @@ function generateScript(inFile, outFile, minify, callback) {
56
64
57
65
// returns the script path for the current platform
58
66
function platformScriptPath ( path ) {
59
- return / ^ w i n / . test ( os . platform ( ) ) ? `${ path } .cmd` : path ;
67
+ return / ^ w i n / . test ( os . platform ( ) ) ? `${ path } .cmd` : path ;
60
68
}
61
69
62
70
function tsc ( config , cb ) {
63
- spawn ( path . normalize ( platformScriptPath ( './node_modules/.bin/tsc' ) ) , [ '-p' , config ] , { stdio : 'inherit' } )
64
- . on ( 'close' , function ( exitCode ) {
65
- if ( exitCode ) {
66
- var err = new Error ( 'TypeScript compiler failed' ) ;
67
- // The stack is not useful in this context.
68
- err . showStack = false ;
69
- cb ( err ) ;
70
- } else {
71
- cb ( ) ;
72
- }
73
- } ) ;
71
+ spawn ( path . normalize ( platformScriptPath ( './node_modules/.bin/tsc' ) ) , [ '-p' , config ] , {
72
+ stdio : 'inherit'
73
+ } ) . on ( 'close' , function ( exitCode ) {
74
+ if ( exitCode ) {
75
+ var err = new Error ( 'TypeScript compiler failed' ) ;
76
+ // The stack is not useful in this context.
77
+ err . showStack = false ;
78
+ cb ( err ) ;
79
+ } else {
80
+ cb ( ) ;
81
+ }
82
+ } ) ;
74
83
}
75
84
76
85
// This is equivalent to `npm run tsc`.
@@ -91,7 +100,9 @@ gulp.task('compile-esm-node', function(cb) {
91
100
} ) ;
92
101
93
102
gulp . task ( 'build/zone.js.d.ts' , [ 'compile-esm' ] , function ( ) {
94
- return gulp . src ( './build-esm/lib/zone.d.ts' ) . pipe ( rename ( 'zone.js.d.ts' ) ) . pipe ( gulp . dest ( './dist' ) ) ;
103
+ return gulp . src ( './build-esm/lib/zone.d.ts' )
104
+ . pipe ( rename ( 'zone.js.d.ts' ) )
105
+ . pipe ( gulp . dest ( './dist' ) ) ;
95
106
} ) ;
96
107
97
108
// Zone for Node.js environment.
@@ -125,7 +136,7 @@ gulp.task('build/zone-testing.js', ['compile-esm'], function(cb) {
125
136
126
137
// Zone for electron/nw environment.
127
138
gulp . task ( 'build/zone-mix.js' , [ 'compile-esm-node' ] , function ( cb ) {
128
- return generateScript ( './lib/mix/rollup-mix.ts' , 'zone-mix.js' , false , cb ) ;
139
+ return generateScript ( './lib/mix/rollup-mix.ts' , 'zone-mix.js' , false , cb ) ;
129
140
} ) ;
130
141
131
142
gulp . task ( 'build/zone-error.js' , [ 'compile-esm' ] , function ( cb ) {
@@ -137,59 +148,68 @@ gulp.task('build/zone-error.min.js', ['compile-esm'], function(cb) {
137
148
} ) ;
138
149
139
150
gulp . task ( 'build/webapis-media-query.js' , [ 'compile-esm' ] , function ( cb ) {
140
- return generateScript ( './lib/browser/webapis-media-query.ts' , 'webapis-media-query.js' , false , cb ) ;
151
+ return generateScript (
152
+ './lib/browser/webapis-media-query.ts' , 'webapis-media-query.js' , false , cb ) ;
141
153
} ) ;
142
154
143
155
gulp . task ( 'build/webapis-media-query.min.js' , [ 'compile-esm' ] , function ( cb ) {
144
- return generateScript ( './lib/browser/webapis-media-query.ts' , 'webapis-media-query.min.js' , true , cb ) ;
156
+ return generateScript (
157
+ './lib/browser/webapis-media-query.ts' , 'webapis-media-query.min.js' , true , cb ) ;
145
158
} ) ;
146
159
147
160
gulp . task ( 'build/webapis-notification.js' , [ 'compile-esm' ] , function ( cb ) {
148
- return generateScript ( './lib/browser/webapis-notification.ts' , 'webapis-notification.js' , false , cb ) ;
161
+ return generateScript (
162
+ './lib/browser/webapis-notification.ts' , 'webapis-notification.js' , false , cb ) ;
149
163
} ) ;
150
164
151
165
gulp . task ( 'build/webapis-notification.min.js' , [ 'compile-esm' ] , function ( cb ) {
152
- return generateScript ( './lib/browser/webapis-notification.ts' , 'webapis-notification.min.js' , true , cb ) ;
166
+ return generateScript (
167
+ './lib/browser/webapis-notification.ts' , 'webapis-notification.min.js' , true , cb ) ;
153
168
} ) ;
154
169
155
170
gulp . task ( 'build/webapis-rtc-peer-connection.js' , [ 'compile-esm' ] , function ( cb ) {
156
- return generateScript ( './lib/browser/webapis-rtc-peer-connection.ts' , 'webapis-rtc-peer-connection.js' , false , cb ) ;
171
+ return generateScript (
172
+ './lib/browser/webapis-rtc-peer-connection.ts' , 'webapis-rtc-peer-connection.js' , false , cb ) ;
157
173
} ) ;
158
174
159
175
gulp . task ( 'build/webapis-rtc-peer-connection.min.js' , [ 'compile-esm' ] , function ( cb ) {
160
- return generateScript ( './lib/browser/webapis-rtc-peer-connection.ts' , 'webapis-rtc-peer-connection.min.js' , true , cb ) ;
176
+ return generateScript (
177
+ './lib/browser/webapis-rtc-peer-connection.ts' , 'webapis-rtc-peer-connection.min.js' , true ,
178
+ cb ) ;
161
179
} ) ;
162
180
163
181
gulp . task ( 'build/webapis-shadydom.js' , [ 'compile-esm' ] , function ( cb ) {
164
- return generateScript ( './lib/browser/shadydom.ts' , 'webapis-shadydom.js' , false , cb ) ;
182
+ return generateScript ( './lib/browser/shadydom.ts' , 'webapis-shadydom.js' , false , cb ) ;
165
183
} ) ;
166
184
167
185
gulp . task ( 'build/webapis-shadydom.min.js' , [ 'compile-esm' ] , function ( cb ) {
168
- return generateScript ( './lib/browser/shadydom.ts' , 'webapis-shadydom.min.js' , true , cb ) ;
186
+ return generateScript ( './lib/browser/shadydom.ts' , 'webapis-shadydom.min.js' , true , cb ) ;
169
187
} ) ;
170
188
171
189
gulp . task ( 'build/zone-patch-cordova.js' , [ 'compile-esm' ] , function ( cb ) {
172
- return generateScript ( './lib/extra/cordova.ts' , 'zone-patch-cordova.js' , false , cb ) ;
190
+ return generateScript ( './lib/extra/cordova.ts' , 'zone-patch-cordova.js' , false , cb ) ;
173
191
} ) ;
174
192
175
193
gulp . task ( 'build/zone-patch-cordova.min.js' , [ 'compile-esm' ] , function ( cb ) {
176
- return generateScript ( './lib/extra/cordova.ts' , 'zone-patch-cordova.min.js' , true , cb ) ;
194
+ return generateScript ( './lib/extra/cordova.ts' , 'zone-patch-cordova.min.js' , true , cb ) ;
177
195
} ) ;
178
196
179
197
gulp . task ( 'build/zone-patch-electron.js' , [ 'compile-esm' ] , function ( cb ) {
180
- return generateScript ( './lib/extra/electron.ts' , 'zone-patch-electron.js' , false , cb ) ;
198
+ return generateScript ( './lib/extra/electron.ts' , 'zone-patch-electron.js' , false , cb ) ;
181
199
} ) ;
182
200
183
201
gulp . task ( 'build/zone-patch-electron.min.js' , [ 'compile-esm' ] , function ( cb ) {
184
- return generateScript ( './lib/extra/electron.ts' , 'zone-patch-electron.min.js' , true , cb ) ;
202
+ return generateScript ( './lib/extra/electron.ts' , 'zone-patch-electron.min.js' , true , cb ) ;
185
203
} ) ;
186
204
187
205
gulp . task ( 'build/zone-patch-user-media.js' , [ 'compile-esm' ] , function ( cb ) {
188
- return generateScript ( './lib/browser/webapis-user-media.ts' , 'zone-patch-user-media.js' , false , cb ) ;
206
+ return generateScript (
207
+ './lib/browser/webapis-user-media.ts' , 'zone-patch-user-media.js' , false , cb ) ;
189
208
} ) ;
190
209
191
210
gulp . task ( 'build/zone-patch-user-media.min.js' , [ 'compile-esm' ] , function ( cb ) {
192
- return generateScript ( './lib/browser/webapis-user-media.ts' , 'zone-patch-user-media.min.js' , true , cb ) ;
211
+ return generateScript (
212
+ './lib/browser/webapis-user-media.ts' , 'zone-patch-user-media.min.js' , true , cb ) ;
193
213
} ) ;
194
214
195
215
gulp . task ( 'build/zone-patch-socket-io.js' , [ 'compile-esm' ] , function ( cb ) {
@@ -209,11 +229,11 @@ gulp.task('build/zone-patch-promise-testing.min.js', ['compile-esm'], function(c
209
229
} ) ;
210
230
211
231
gulp . task ( 'build/bluebird.js' , [ 'compile-esm' ] , function ( cb ) {
212
- return generateScript ( './lib/extra/bluebird.ts' , 'zone-bluebird.js' , false , cb ) ;
232
+ return generateScript ( './lib/extra/bluebird.ts' , 'zone-bluebird.js' , false , cb ) ;
213
233
} ) ;
214
234
215
235
gulp . task ( 'build/bluebird.min.js' , [ 'compile-esm' ] , function ( cb ) {
216
- return generateScript ( './lib/extra/bluebird.ts' , 'zone-bluebird.min.js' , true , cb ) ;
236
+ return generateScript ( './lib/extra/bluebird.ts' , 'zone-bluebird.min.js' , true , cb ) ;
217
237
} ) ;
218
238
219
239
gulp . task ( 'build/zone-patch-jsonp.js' , [ 'compile-esm' ] , function ( cb ) {
@@ -241,11 +261,13 @@ gulp.task('build/mocha-patch.min.js', ['compile-esm'], function(cb) {
241
261
} ) ;
242
262
243
263
gulp . task ( 'build/long-stack-trace-zone.js' , [ 'compile-esm' ] , function ( cb ) {
244
- return generateScript ( './lib/zone-spec/long-stack-trace.ts' , 'long-stack-trace-zone.js' , false , cb ) ;
264
+ return generateScript (
265
+ './lib/zone-spec/long-stack-trace.ts' , 'long-stack-trace-zone.js' , false , cb ) ;
245
266
} ) ;
246
267
247
268
gulp . task ( 'build/long-stack-trace-zone.min.js' , [ 'compile-esm' ] , function ( cb ) {
248
- return generateScript ( './lib/zone-spec/long-stack-trace.ts' , 'long-stack-trace-zone.min.js' , true , cb ) ;
269
+ return generateScript (
270
+ './lib/zone-spec/long-stack-trace.ts' , 'long-stack-trace-zone.min.js' , true , cb ) ;
249
271
} ) ;
250
272
251
273
gulp . task ( 'build/proxy-zone.js' , [ 'compile-esm' ] , function ( cb ) {
@@ -301,8 +323,7 @@ gulp.task('build/rxjs-fake-async.min.js', ['compile-esm'], function(cb) {
301
323
} ) ;
302
324
303
325
gulp . task ( 'build/closure.js' , function ( ) {
304
- return gulp . src ( './lib/closure/zone_externs.js' )
305
- . pipe ( gulp . dest ( './dist' ) ) ;
326
+ return gulp . src ( './lib/closure/zone_externs.js' ) . pipe ( gulp . dest ( './dist' ) ) ;
306
327
} ) ;
307
328
308
329
gulp . task ( 'build' , [
@@ -396,12 +417,12 @@ gulp.task('lint', () => {
396
417
const tslintConfig = require ( './tslint.json' ) ;
397
418
398
419
return gulp . src ( [ 'lib/**/*.ts' , 'test/**/*.ts' ] )
399
- . pipe ( tslint ( {
400
- tslint : require ( 'tslint' ) . default ,
401
- configuration : tslintConfig ,
402
- formatter : 'prose' ,
403
- } ) )
404
- . pipe ( tslint . report ( { emitError : true } ) ) ;
420
+ . pipe ( tslint ( {
421
+ tslint : require ( 'tslint' ) . default ,
422
+ configuration : tslintConfig ,
423
+ formatter : 'prose' ,
424
+ } ) )
425
+ . pipe ( tslint . report ( { emitError : true } ) ) ;
405
426
} ) ;
406
427
407
428
// clang-format entry points
@@ -415,51 +436,52 @@ gulp.task('format:enforce', () => {
415
436
const format = require ( 'gulp-clang-format' ) ;
416
437
const clangFormat = require ( 'clang-format' ) ;
417
438
return gulp . src ( srcsToFmt ) . pipe (
418
- format . checkFormat ( 'file' , clangFormat , { verbose : true , fail : true } ) ) ;
439
+ format . checkFormat ( 'file' , clangFormat , { verbose : true , fail : true } ) ) ;
419
440
} ) ;
420
441
421
442
// Format the source code with clang-format (see .clang-format)
422
443
gulp . task ( 'format' , ( ) => {
423
444
const format = require ( 'gulp-clang-format' ) ;
424
445
const clangFormat = require ( 'clang-format' ) ;
425
- return gulp . src ( srcsToFmt , { base : '.' } ) . pipe (
426
- format . format ( 'file' , clangFormat ) ) . pipe ( gulp . dest ( '.' ) ) ;
446
+ return gulp . src ( srcsToFmt , { base : '.' } )
447
+ . pipe ( format . format ( 'file' , clangFormat ) )
448
+ . pipe ( gulp . dest ( '.' ) ) ;
427
449
} ) ;
428
450
429
451
// Update the changelog with the latest changes
430
452
gulp . task ( 'changelog' , ( ) => {
431
453
const conventionalChangelog = require ( 'gulp-conventional-changelog' ) ;
432
454
433
455
return gulp . src ( 'CHANGELOG.md' )
434
- . pipe ( conventionalChangelog ( { preset : 'angular' , releaseCount : 1 } , {
435
- // Conventional Changelog Context
436
- // We have to manually set version number so it doesn't get prefixed with `v`
437
- // See https://github.com/conventional-changelog/conventional-changelog-core/issues/10
438
- currentTag : require ( './package.json' ) . version
439
- } ) )
440
- . pipe ( gulp . dest ( './' ) ) ;
456
+ . pipe ( conventionalChangelog ( { preset : 'angular' , releaseCount : 1 } , {
457
+ // Conventional Changelog Context
458
+ // We have to manually set version number so it doesn't get prefixed with `v`
459
+ // See https://github.com/conventional-changelog/conventional-changelog-core/issues/10
460
+ currentTag : require ( './package.json' ) . version
461
+ } ) )
462
+ . pipe ( gulp . dest ( './' ) ) ;
441
463
} ) ;
442
464
443
465
// run promise aplus test
444
466
gulp . task ( 'promisetest' , [ 'build/zone-node.js' ] , ( cb ) => {
445
- const promisesAplusTests = require ( 'promises-aplus-tests' ) ;
446
- const adapter = require ( './promise-adapter' ) ;
447
- promisesAplusTests ( adapter , { reporter : " dot" } , function ( err ) {
448
- if ( err ) {
449
- cb ( err ) ;
450
- } else {
451
- cb ( ) ;
452
- }
453
- } ) ;
467
+ const promisesAplusTests = require ( 'promises-aplus-tests' ) ;
468
+ const adapter = require ( './promise-adapter' ) ;
469
+ promisesAplusTests ( adapter , { reporter : ' dot' } , function ( err ) {
470
+ if ( err ) {
471
+ cb ( err ) ;
472
+ } else {
473
+ cb ( ) ;
474
+ }
475
+ } ) ;
454
476
} ) ;
455
477
456
478
// check dist file size limitation
457
479
gulp . task ( 'filesize' , [ 'build' ] , ( cb ) => {
458
- const checker = require ( './check-file-size' ) ;
459
- const result = checker ( require ( './file-size-limit.json' ) ) ;
460
- if ( result ) {
461
- cb ( ) ;
462
- } else {
463
- cb ( 'check file size failed' ) ;
464
- }
480
+ const checker = require ( './check-file-size' ) ;
481
+ const result = checker ( require ( './file-size-limit.json' ) ) ;
482
+ if ( result ) {
483
+ cb ( ) ;
484
+ } else {
485
+ cb ( 'check file size failed' ) ;
486
+ }
465
487
} ) ;
0 commit comments