@@ -63,7 +63,8 @@ gulp.task('build-browser', function () {
63
63
cache : { } ,
64
64
standalone : 'neo4j' ,
65
65
packageCache : { }
66
- } ) . transform ( babelifyTransform ( ) )
66
+ } )
67
+ . transform ( babelifyTransform ( ) )
67
68
. transform ( browserifyTransformNodeToBrowserRequire ( ) )
68
69
. bundle ( )
69
70
@@ -84,39 +85,50 @@ gulp.task('build-browser', function () {
84
85
gulp . task ( 'build-browser-test' , function ( ) {
85
86
var browserOutput = 'build/browser/'
86
87
var testFiles = [ ]
87
- return gulp . src ( [ './test/**/*.test.js' , '!./test/**/node/*.js' ] )
88
- . pipe ( through . obj ( function ( file , enc , cb ) {
89
- if ( file . path . indexOf ( 'examples.test.js' ) < 0 ) {
90
- testFiles . push ( file . path )
91
- }
92
- cb ( )
93
- } , function ( cb ) {
94
- // At end-of-stream, push the list of files to the next step
95
- this . push ( testFiles )
96
- cb ( )
97
- } ) )
98
- . pipe ( through . obj ( function ( testFiles , enc , cb ) {
99
- browserify ( {
100
- entries : testFiles ,
101
- cache : { } ,
102
- debug : true
103
- } ) . transform ( babelifyTransform ( ) )
104
- . transform ( browserifyTransformNodeToBrowserRequire ( ) )
105
- . bundle ( function ( ) {
88
+ return gulp
89
+ . src ( [ './test/**/*.test.js' , '!./test/**/node/*.js' ] )
90
+ . pipe (
91
+ through . obj (
92
+ function ( file , enc , cb ) {
93
+ if ( file . path . indexOf ( 'examples.test.js' ) < 0 ) {
94
+ testFiles . push ( file . path )
95
+ }
106
96
cb ( )
107
- } )
108
- . on ( 'error' , gutil . log )
109
- . pipe ( source ( 'neo4j-web.test.js' ) )
110
- . pipe ( gulp . dest ( browserOutput ) )
111
- } ,
112
- function ( cb ) {
113
- cb ( )
114
- }
115
- ) )
97
+ } ,
98
+ function ( cb ) {
99
+ // At end-of-stream, push the list of files to the next step
100
+ this . push ( testFiles )
101
+ cb ( )
102
+ }
103
+ )
104
+ )
105
+ . pipe (
106
+ through . obj (
107
+ function ( testFiles , enc , cb ) {
108
+ browserify ( {
109
+ entries : testFiles ,
110
+ cache : { } ,
111
+ debug : true
112
+ } )
113
+ . transform ( babelifyTransform ( ) )
114
+ . transform ( browserifyTransformNodeToBrowserRequire ( ) )
115
+ . bundle ( function ( ) {
116
+ cb ( )
117
+ } )
118
+ . on ( 'error' , gutil . log )
119
+ . pipe ( source ( 'neo4j-web.test.js' ) )
120
+ . pipe ( gulp . dest ( browserOutput ) )
121
+ } ,
122
+ function ( cb ) {
123
+ cb ( )
124
+ }
125
+ )
126
+ )
116
127
} )
117
128
118
129
var buildNode = function ( options ) {
119
- return gulp . src ( options . src )
130
+ return gulp
131
+ . src ( options . src )
120
132
. pipe ( babel ( babelConfig ( ) ) )
121
133
. pipe ( gulp . dest ( options . dest ) )
122
134
}
@@ -138,8 +150,8 @@ gulp.task('install-driver-into-sandbox', ['nodejs'], function () {
138
150
fs . emptyDirSync ( testDir )
139
151
140
152
var packageJsonContent = JSON . stringify ( {
141
- ' private' : true ,
142
- ' dependencies' : {
153
+ private : true ,
154
+ dependencies : {
143
155
'neo4j-driver' : __dirname
144
156
}
145
157
} )
@@ -150,22 +162,31 @@ gulp.task('install-driver-into-sandbox', ['nodejs'], function () {
150
162
} )
151
163
152
164
gulp . task ( 'test' , function ( cb ) {
153
- runSequence ( 'run-ts-declaration-tests' , 'test-nodejs' , 'test-browser' , function ( err ) {
154
- if ( err ) {
155
- var exitCode = 2
156
- console . log ( '[FAIL] test task failed - exiting with code ' + exitCode )
157
- return process . exit ( exitCode )
165
+ runSequence (
166
+ 'run-ts-declaration-tests' ,
167
+ 'test-nodejs' ,
168
+ 'test-browser' ,
169
+ function ( err ) {
170
+ if ( err ) {
171
+ var exitCode = 2
172
+ console . log ( '[FAIL] test task failed - exiting with code ' + exitCode )
173
+ return process . exit ( exitCode )
174
+ }
175
+ return cb ( )
158
176
}
159
- return cb ( )
160
- } )
177
+ )
161
178
} )
162
179
163
180
gulp . task ( 'test-nodejs' , [ 'install-driver-into-sandbox' ] , function ( ) {
164
- return gulp . src ( [ './test/**/*.test.js' , '!./test/**/browser/*.js' ] )
165
- . pipe ( jasmine ( {
166
- includeStackTrace : true ,
167
- reporter : newJasmineConsoleReporter ( )
168
- } ) ) . on ( 'end' , logActiveNodeHandles )
181
+ return gulp
182
+ . src ( [ './test/**/*.test.js' , '!./test/**/browser/*.js' ] )
183
+ . pipe (
184
+ jasmine ( {
185
+ includeStackTrace : true ,
186
+ reporter : newJasmineConsoleReporter ( )
187
+ } )
188
+ )
189
+ . on ( 'end' , logActiveNodeHandles )
169
190
} )
170
191
171
192
gulp . task ( 'test-browser' , function ( cb ) {
@@ -193,9 +214,12 @@ gulp.task('run-browser-test-ie', function (cb) {
193
214
} )
194
215
195
216
gulp . task ( 'watch' , function ( ) {
196
- return watch ( 'src/**/*.js' , batch ( function ( events , done ) {
197
- gulp . start ( 'all' , done )
198
- } ) )
217
+ return watch (
218
+ 'src/**/*.js' ,
219
+ batch ( function ( events , done ) {
220
+ gulp . start ( 'all' , done )
221
+ } )
222
+ )
199
223
} )
200
224
201
225
gulp . task ( 'watch-n-test' , [ 'test-nodejs' ] , function ( ) {
@@ -213,7 +237,8 @@ gulp.task('set', function () {
213
237
214
238
// Change the version in relevant files
215
239
var versionFile = path . join ( 'src' , 'version.js' )
216
- return gulp . src ( [ versionFile ] , { base : './' } )
240
+ return gulp
241
+ . src ( [ versionFile ] , { base : './' } )
217
242
. pipe ( replace ( '0.0.0-dev' , version ) )
218
243
. pipe ( gulp . dest ( './' ) )
219
244
} )
@@ -231,30 +256,39 @@ gulp.task('stop-neo4j', function (done) {
231
256
} )
232
257
233
258
gulp . task ( 'run-stress-tests' , function ( ) {
234
- return gulp . src ( 'test/**/stress.test.js' )
235
- . pipe ( jasmine ( {
236
- includeStackTrace : true ,
237
- reporter : newJasmineConsoleReporter ( )
238
- } ) ) . on ( 'end' , logActiveNodeHandles )
259
+ return gulp
260
+ . src ( 'test/**/stress.test.js' )
261
+ . pipe (
262
+ jasmine ( {
263
+ includeStackTrace : true ,
264
+ reporter : newJasmineConsoleReporter ( )
265
+ } )
266
+ )
267
+ . on ( 'end' , logActiveNodeHandles )
239
268
} )
240
269
241
270
gulp . task ( 'run-ts-declaration-tests' , function ( ) {
242
271
var failed = false
243
272
244
- return gulp . src ( [ 'test/types/**/*' , 'types/**/*' ] , { base : '.' } )
245
- . pipe ( ts ( {
246
- module : 'es6' ,
247
- target : 'es6' ,
248
- noImplicitAny : true ,
249
- noImplicitReturns : true ,
250
- strictNullChecks : true
251
- } ) )
273
+ return gulp
274
+ . src ( [ 'test/types/**/*' , 'types/**/*' ] , { base : '.' } )
275
+ . pipe (
276
+ ts ( {
277
+ module : 'es6' ,
278
+ target : 'es6' ,
279
+ noImplicitAny : true ,
280
+ noImplicitReturns : true ,
281
+ strictNullChecks : true
282
+ } )
283
+ )
252
284
. on ( 'error' , function ( ) {
253
285
failed = true
254
286
} )
255
287
. on ( 'finish' , function ( ) {
256
288
if ( failed ) {
257
- console . log ( '[ERROR] TypeScript declarations contain errors. Exiting...' )
289
+ console . log (
290
+ '[ERROR] TypeScript declarations contain errors. Exiting...'
291
+ )
258
292
process . exit ( 1 )
259
293
}
260
294
} )
@@ -263,7 +297,11 @@ gulp.task('run-ts-declaration-tests', function () {
263
297
264
298
function logActiveNodeHandles ( ) {
265
299
if ( enableActiveNodeHandlesLogging ) {
266
- console . log ( '-- Active NodeJS handles START\n' , process . _getActiveHandles ( ) , '\n-- Active NodeJS handles END' )
300
+ console . log (
301
+ '-- Active NodeJS handles START\n' ,
302
+ process . _getActiveHandles ( ) ,
303
+ '\n-- Active NodeJS handles END'
304
+ )
267
305
}
268
306
}
269
307
@@ -283,33 +321,43 @@ function babelifyTransform () {
283
321
284
322
function babelConfig ( ) {
285
323
return {
286
- presets : [ 'env' ] , plugins : [ 'transform-runtime' ]
324
+ presets : [ 'env' ] ,
325
+ plugins : [ 'transform-runtime' ]
287
326
}
288
327
}
289
328
290
329
function browserifyTransformNodeToBrowserRequire ( ) {
291
330
var nodeRequire = '/node'
292
331
var browserRequire = '/browser'
293
332
294
- return transformTools . makeRequireTransform ( 'bodeToBrowserRequireTransform' ,
333
+ return transformTools . makeRequireTransform (
334
+ 'bodeToBrowserRequireTransform' ,
295
335
{ evaluateArguments : true } ,
296
336
function ( args , opts , cb ) {
297
337
var requireArg = args [ 0 ]
298
- var endsWithNodeRequire = requireArg . slice ( - nodeRequire . length ) === nodeRequire
338
+ var endsWithNodeRequire =
339
+ requireArg . slice ( - nodeRequire . length ) === nodeRequire
299
340
if ( endsWithNodeRequire ) {
300
341
var newRequireArg = requireArg . replace ( nodeRequire , browserRequire )
301
- return cb ( null , ' require(\'' + newRequireArg + '\')' )
342
+ return cb ( null , " require('" + newRequireArg + "')" )
302
343
} else {
303
344
return cb ( )
304
345
}
305
- } )
346
+ }
347
+ )
306
348
}
307
349
308
350
function runKarma ( browser , cb ) {
309
- new karma . Server ( {
310
- configFile : path . join ( __dirname , `/test/browser/karma-${ browser } .conf.js` ) ,
311
- singleRun : true
312
- } , function ( exitCode ) {
313
- exitCode ? process . exit ( exitCode ) : cb ( )
314
- } ) . start ( )
351
+ new karma . Server (
352
+ {
353
+ configFile : path . join (
354
+ __dirname ,
355
+ `/test/browser/karma-${ browser } .conf.js`
356
+ ) ,
357
+ singleRun : true
358
+ } ,
359
+ function ( exitCode ) {
360
+ exitCode ? process . exit ( exitCode ) : cb ( )
361
+ }
362
+ ) . start ( )
315
363
}
0 commit comments