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,22 +21,28 @@ 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 ,
24
+ input : inFile ,
25
25
format : 'umd' ,
26
- onwarn : function ( warning ) {
26
+ onwarn : function ( warning ) {
27
27
// https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
28
28
if ( warning . code === 'THIS_IS_UNDEFINED' ) {
29
29
return ;
30
30
}
31
31
console . error ( warning . message ) ;
32
32
} ,
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
- + '*/' ,
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
+ external : id => {
41
+ if ( / b u i l d - e s m / . test ( id ) ) {
42
+ return false ;
43
+ }
44
+ return / r x j s / . test ( id ) ;
45
+ } ,
40
46
globals : {
41
47
'rxjs/Observable' : 'Rx' ,
42
48
'rxjs/Subscriber' : 'Rx' ,
@@ -56,21 +62,22 @@ function generateScript(inFile, outFile, minify, callback) {
56
62
57
63
// returns the script path for the current platform
58
64
function platformScriptPath ( path ) {
59
- return / ^ w i n / . test ( os . platform ( ) ) ? `${ path } .cmd` : path ;
65
+ return / ^ w i n / . test ( os . platform ( ) ) ? `${ path } .cmd` : path ;
60
66
}
61
67
62
68
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
- } ) ;
69
+ spawn ( path . normalize ( platformScriptPath ( './node_modules/.bin/tsc' ) ) , [ '-p' , config ] , {
70
+ stdio : 'inherit'
71
+ } ) . on ( 'close' , function ( exitCode ) {
72
+ if ( exitCode ) {
73
+ var err = new Error ( 'TypeScript compiler failed' ) ;
74
+ // The stack is not useful in this context.
75
+ err . showStack = false ;
76
+ cb ( err ) ;
77
+ } else {
78
+ cb ( ) ;
79
+ }
80
+ } ) ;
74
81
}
75
82
76
83
// This is equivalent to `npm run tsc`.
@@ -91,7 +98,9 @@ gulp.task('compile-esm-node', function(cb) {
91
98
} ) ;
92
99
93
100
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' ) ) ;
101
+ return gulp . src ( './build-esm/lib/zone.d.ts' )
102
+ . pipe ( rename ( 'zone.js.d.ts' ) )
103
+ . pipe ( gulp . dest ( './dist' ) ) ;
95
104
} ) ;
96
105
97
106
// Zone for Node.js environment.
@@ -125,7 +134,7 @@ gulp.task('build/zone-testing.js', ['compile-esm'], function(cb) {
125
134
126
135
// Zone for electron/nw environment.
127
136
gulp . task ( 'build/zone-mix.js' , [ 'compile-esm-node' ] , function ( cb ) {
128
- return generateScript ( './lib/mix/rollup-mix.ts' , 'zone-mix.js' , false , cb ) ;
137
+ return generateScript ( './lib/mix/rollup-mix.ts' , 'zone-mix.js' , false , cb ) ;
129
138
} ) ;
130
139
131
140
gulp . task ( 'build/zone-error.js' , [ 'compile-esm' ] , function ( cb ) {
@@ -137,59 +146,68 @@ gulp.task('build/zone-error.min.js', ['compile-esm'], function(cb) {
137
146
} ) ;
138
147
139
148
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 ) ;
149
+ return generateScript (
150
+ './lib/browser/webapis-media-query.ts' , 'webapis-media-query.js' , false , cb ) ;
141
151
} ) ;
142
152
143
153
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 ) ;
154
+ return generateScript (
155
+ './lib/browser/webapis-media-query.ts' , 'webapis-media-query.min.js' , true , cb ) ;
145
156
} ) ;
146
157
147
158
gulp . task ( 'build/webapis-notification.js' , [ 'compile-esm' ] , function ( cb ) {
148
- return generateScript ( './lib/browser/webapis-notification.ts' , 'webapis-notification.js' , false , cb ) ;
159
+ return generateScript (
160
+ './lib/browser/webapis-notification.ts' , 'webapis-notification.js' , false , cb ) ;
149
161
} ) ;
150
162
151
163
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 ) ;
164
+ return generateScript (
165
+ './lib/browser/webapis-notification.ts' , 'webapis-notification.min.js' , true , cb ) ;
153
166
} ) ;
154
167
155
168
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 ) ;
169
+ return generateScript (
170
+ './lib/browser/webapis-rtc-peer-connection.ts' , 'webapis-rtc-peer-connection.js' , false , cb ) ;
157
171
} ) ;
158
172
159
173
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 ) ;
174
+ return generateScript (
175
+ './lib/browser/webapis-rtc-peer-connection.ts' , 'webapis-rtc-peer-connection.min.js' , true ,
176
+ cb ) ;
161
177
} ) ;
162
178
163
179
gulp . task ( 'build/webapis-shadydom.js' , [ 'compile-esm' ] , function ( cb ) {
164
- return generateScript ( './lib/browser/shadydom.ts' , 'webapis-shadydom.js' , false , cb ) ;
180
+ return generateScript ( './lib/browser/shadydom.ts' , 'webapis-shadydom.js' , false , cb ) ;
165
181
} ) ;
166
182
167
183
gulp . task ( 'build/webapis-shadydom.min.js' , [ 'compile-esm' ] , function ( cb ) {
168
- return generateScript ( './lib/browser/shadydom.ts' , 'webapis-shadydom.min.js' , true , cb ) ;
184
+ return generateScript ( './lib/browser/shadydom.ts' , 'webapis-shadydom.min.js' , true , cb ) ;
169
185
} ) ;
170
186
171
187
gulp . task ( 'build/zone-patch-cordova.js' , [ 'compile-esm' ] , function ( cb ) {
172
- return generateScript ( './lib/extra/cordova.ts' , 'zone-patch-cordova.js' , false , cb ) ;
188
+ return generateScript ( './lib/extra/cordova.ts' , 'zone-patch-cordova.js' , false , cb ) ;
173
189
} ) ;
174
190
175
191
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 ) ;
192
+ return generateScript ( './lib/extra/cordova.ts' , 'zone-patch-cordova.min.js' , true , cb ) ;
177
193
} ) ;
178
194
179
195
gulp . task ( 'build/zone-patch-electron.js' , [ 'compile-esm' ] , function ( cb ) {
180
- return generateScript ( './lib/extra/electron.ts' , 'zone-patch-electron.js' , false , cb ) ;
196
+ return generateScript ( './lib/extra/electron.ts' , 'zone-patch-electron.js' , false , cb ) ;
181
197
} ) ;
182
198
183
199
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 ) ;
200
+ return generateScript ( './lib/extra/electron.ts' , 'zone-patch-electron.min.js' , true , cb ) ;
185
201
} ) ;
186
202
187
203
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 ) ;
204
+ return generateScript (
205
+ './lib/browser/webapis-user-media.ts' , 'zone-patch-user-media.js' , false , cb ) ;
189
206
} ) ;
190
207
191
208
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 ) ;
209
+ return generateScript (
210
+ './lib/browser/webapis-user-media.ts' , 'zone-patch-user-media.min.js' , true , cb ) ;
193
211
} ) ;
194
212
195
213
gulp . task ( 'build/zone-patch-socket-io.js' , [ 'compile-esm' ] , function ( cb ) {
@@ -201,11 +219,11 @@ gulp.task('build/zone-patch-socket-io.min.js', ['compile-esm'], function(cb) {
201
219
} ) ;
202
220
203
221
gulp . task ( 'build/bluebird.js' , [ 'compile-esm' ] , function ( cb ) {
204
- return generateScript ( './lib/extra/bluebird.ts' , 'zone-bluebird.js' , false , cb ) ;
222
+ return generateScript ( './lib/extra/bluebird.ts' , 'zone-bluebird.js' , false , cb ) ;
205
223
} ) ;
206
224
207
225
gulp . task ( 'build/bluebird.min.js' , [ 'compile-esm' ] , function ( cb ) {
208
- return generateScript ( './lib/extra/bluebird.ts' , 'zone-bluebird.min.js' , true , cb ) ;
226
+ return generateScript ( './lib/extra/bluebird.ts' , 'zone-bluebird.min.js' , true , cb ) ;
209
227
} ) ;
210
228
211
229
gulp . task ( 'build/jasmine-patch.js' , [ 'compile-esm' ] , function ( cb ) {
@@ -225,11 +243,13 @@ gulp.task('build/mocha-patch.min.js', ['compile-esm'], function(cb) {
225
243
} ) ;
226
244
227
245
gulp . task ( 'build/long-stack-trace-zone.js' , [ 'compile-esm' ] , function ( cb ) {
228
- return generateScript ( './lib/zone-spec/long-stack-trace.ts' , 'long-stack-trace-zone.js' , false , cb ) ;
246
+ return generateScript (
247
+ './lib/zone-spec/long-stack-trace.ts' , 'long-stack-trace-zone.js' , false , cb ) ;
229
248
} ) ;
230
249
231
250
gulp . task ( 'build/long-stack-trace-zone.min.js' , [ 'compile-esm' ] , function ( cb ) {
232
- return generateScript ( './lib/zone-spec/long-stack-trace.ts' , 'long-stack-trace-zone.min.js' , true , cb ) ;
251
+ return generateScript (
252
+ './lib/zone-spec/long-stack-trace.ts' , 'long-stack-trace-zone.min.js' , true , cb ) ;
233
253
} ) ;
234
254
235
255
gulp . task ( 'build/proxy-zone.js' , [ 'compile-esm' ] , function ( cb ) {
@@ -277,8 +297,7 @@ gulp.task('build/rxjs.min.js', ['compile-esm'], function(cb) {
277
297
} ) ;
278
298
279
299
gulp . task ( 'build/closure.js' , function ( ) {
280
- return gulp . src ( './lib/closure/zone_externs.js' )
281
- . pipe ( gulp . dest ( './dist' ) ) ;
300
+ return gulp . src ( './lib/closure/zone_externs.js' ) . pipe ( gulp . dest ( './dist' ) ) ;
282
301
} ) ;
283
302
284
303
gulp . task ( 'build' , [
@@ -366,12 +385,12 @@ gulp.task('lint', () => {
366
385
const tslintConfig = require ( './tslint.json' ) ;
367
386
368
387
return gulp . src ( [ 'lib/**/*.ts' , 'test/**/*.ts' ] )
369
- . pipe ( tslint ( {
370
- tslint : require ( 'tslint' ) . default ,
371
- configuration : tslintConfig ,
372
- formatter : 'prose' ,
373
- } ) )
374
- . pipe ( tslint . report ( { emitError : true } ) ) ;
388
+ . pipe ( tslint ( {
389
+ tslint : require ( 'tslint' ) . default ,
390
+ configuration : tslintConfig ,
391
+ formatter : 'prose' ,
392
+ } ) )
393
+ . pipe ( tslint . report ( { emitError : true } ) ) ;
375
394
} ) ;
376
395
377
396
// clang-format entry points
@@ -385,49 +404,50 @@ gulp.task('format:enforce', () => {
385
404
const format = require ( 'gulp-clang-format' ) ;
386
405
const clangFormat = require ( 'clang-format' ) ;
387
406
return gulp . src ( srcsToFmt ) . pipe (
388
- format . checkFormat ( 'file' , clangFormat , { verbose : true , fail : true } ) ) ;
407
+ format . checkFormat ( 'file' , clangFormat , { verbose : true , fail : true } ) ) ;
389
408
} ) ;
390
409
391
410
// Format the source code with clang-format (see .clang-format)
392
411
gulp . task ( 'format' , ( ) => {
393
412
const format = require ( 'gulp-clang-format' ) ;
394
413
const clangFormat = require ( 'clang-format' ) ;
395
- return gulp . src ( srcsToFmt , { base : '.' } ) . pipe (
396
- format . format ( 'file' , clangFormat ) ) . pipe ( gulp . dest ( '.' ) ) ;
414
+ return gulp . src ( srcsToFmt , { base : '.' } )
415
+ . pipe ( format . format ( 'file' , clangFormat ) )
416
+ . pipe ( gulp . dest ( '.' ) ) ;
397
417
} ) ;
398
418
399
419
// Update the changelog with the latest changes
400
420
gulp . task ( 'changelog' , ( ) => {
401
421
const conventionalChangelog = require ( 'gulp-conventional-changelog' ) ;
402
422
403
423
return gulp . src ( 'CHANGELOG.md' )
404
- . pipe ( conventionalChangelog ( { preset : 'angular' , releaseCount : 1 } , {
405
- // Conventional Changelog Context
406
- // We have to manually set version number so it doesn't get prefixed with `v`
407
- // See https://github.com/conventional-changelog/conventional-changelog-core/issues/10
408
- currentTag : require ( './package.json' ) . version
409
- } ) )
410
- . pipe ( gulp . dest ( './' ) ) ;
424
+ . pipe ( conventionalChangelog ( { preset : 'angular' , releaseCount : 1 } , {
425
+ // Conventional Changelog Context
426
+ // We have to manually set version number so it doesn't get prefixed with `v`
427
+ // See https://github.com/conventional-changelog/conventional-changelog-core/issues/10
428
+ currentTag : require ( './package.json' ) . version
429
+ } ) )
430
+ . pipe ( gulp . dest ( './' ) ) ;
411
431
} ) ;
412
432
413
433
// run promise aplus test
414
434
gulp . task ( 'promisetest' , [ 'build/zone-node.js' ] , ( cb ) => {
415
- const promisesAplusTests = require ( 'promises-aplus-tests' ) ;
416
- const adapter = require ( './promise-adapter' ) ;
417
- promisesAplusTests ( adapter , { reporter : " dot" } , function ( err ) {
418
- if ( err ) {
419
- cb ( err ) ;
420
- }
421
- } ) ;
435
+ const promisesAplusTests = require ( 'promises-aplus-tests' ) ;
436
+ const adapter = require ( './promise-adapter' ) ;
437
+ promisesAplusTests ( adapter , { reporter : ' dot' } , function ( err ) {
438
+ if ( err ) {
439
+ cb ( err ) ;
440
+ }
441
+ } ) ;
422
442
} ) ;
423
443
424
444
// check dist file size limitation
425
445
gulp . task ( 'filesize' , [ 'build' ] , ( cb ) => {
426
- const checker = require ( './check-file-size' ) ;
427
- const result = checker ( require ( './file-size-limit.json' ) ) ;
428
- if ( result ) {
429
- cb ( ) ;
430
- } else {
431
- cb ( 'check file size failed' ) ;
432
- }
446
+ const checker = require ( './check-file-size' ) ;
447
+ const result = checker ( require ( './file-size-limit.json' ) ) ;
448
+ if ( result ) {
449
+ cb ( ) ;
450
+ } else {
451
+ cb ( 'check file size failed' ) ;
452
+ }
433
453
} ) ;
0 commit comments