@@ -63,7 +63,8 @@ gulp.task('build-browser', function () {
6363 cache : { } ,
6464 standalone : 'neo4j' ,
6565 packageCache : { }
66- } ) . transform ( babelifyTransform ( ) )
66+ } )
67+ . transform ( babelifyTransform ( ) )
6768 . transform ( browserifyTransformNodeToBrowserRequire ( ) )
6869 . bundle ( )
6970
@@ -84,39 +85,50 @@ gulp.task('build-browser', function () {
8485gulp . task ( 'build-browser-test' , function ( ) {
8586 var browserOutput = 'build/browser/'
8687 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+ }
10696 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+ )
116127} )
117128
118129var buildNode = function ( options ) {
119- return gulp . src ( options . src )
130+ return gulp
131+ . src ( options . src )
120132 . pipe ( babel ( babelConfig ( ) ) )
121133 . pipe ( gulp . dest ( options . dest ) )
122134}
@@ -138,8 +150,8 @@ gulp.task('install-driver-into-sandbox', ['nodejs'], function () {
138150 fs . emptyDirSync ( testDir )
139151
140152 var packageJsonContent = JSON . stringify ( {
141- ' private' : true ,
142- ' dependencies' : {
153+ private : true ,
154+ dependencies : {
143155 'neo4j-driver' : __dirname
144156 }
145157 } )
@@ -150,22 +162,31 @@ gulp.task('install-driver-into-sandbox', ['nodejs'], function () {
150162} )
151163
152164gulp . 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 ( )
158176 }
159- return cb ( )
160- } )
177+ )
161178} )
162179
163180gulp . 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 )
169190} )
170191
171192gulp . task ( 'test-browser' , function ( cb ) {
@@ -193,9 +214,12 @@ gulp.task('run-browser-test-ie', function (cb) {
193214} )
194215
195216gulp . 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+ )
199223} )
200224
201225gulp . task ( 'watch-n-test' , [ 'test-nodejs' ] , function ( ) {
@@ -213,7 +237,8 @@ gulp.task('set', function () {
213237
214238 // Change the version in relevant files
215239 var versionFile = path . join ( 'src' , 'version.js' )
216- return gulp . src ( [ versionFile ] , { base : './' } )
240+ return gulp
241+ . src ( [ versionFile ] , { base : './' } )
217242 . pipe ( replace ( '0.0.0-dev' , version ) )
218243 . pipe ( gulp . dest ( './' ) )
219244} )
@@ -231,30 +256,39 @@ gulp.task('stop-neo4j', function (done) {
231256} )
232257
233258gulp . 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 )
239268} )
240269
241270gulp . task ( 'run-ts-declaration-tests' , function ( ) {
242271 var failed = false
243272
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+ )
252284 . on ( 'error' , function ( ) {
253285 failed = true
254286 } )
255287 . on ( 'finish' , function ( ) {
256288 if ( failed ) {
257- console . log ( '[ERROR] TypeScript declarations contain errors. Exiting...' )
289+ console . log (
290+ '[ERROR] TypeScript declarations contain errors. Exiting...'
291+ )
258292 process . exit ( 1 )
259293 }
260294 } )
@@ -263,7 +297,11 @@ gulp.task('run-ts-declaration-tests', function () {
263297
264298function logActiveNodeHandles ( ) {
265299 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+ )
267305 }
268306}
269307
@@ -283,33 +321,43 @@ function babelifyTransform () {
283321
284322function babelConfig ( ) {
285323 return {
286- presets : [ 'env' ] , plugins : [ 'transform-runtime' ]
324+ presets : [ 'env' ] ,
325+ plugins : [ 'transform-runtime' ]
287326 }
288327}
289328
290329function browserifyTransformNodeToBrowserRequire ( ) {
291330 var nodeRequire = '/node'
292331 var browserRequire = '/browser'
293332
294- return transformTools . makeRequireTransform ( 'bodeToBrowserRequireTransform' ,
333+ return transformTools . makeRequireTransform (
334+ 'bodeToBrowserRequireTransform' ,
295335 { evaluateArguments : true } ,
296336 function ( args , opts , cb ) {
297337 var requireArg = args [ 0 ]
298- var endsWithNodeRequire = requireArg . slice ( - nodeRequire . length ) === nodeRequire
338+ var endsWithNodeRequire =
339+ requireArg . slice ( - nodeRequire . length ) === nodeRequire
299340 if ( endsWithNodeRequire ) {
300341 var newRequireArg = requireArg . replace ( nodeRequire , browserRequire )
301- return cb ( null , ' require(\'' + newRequireArg + '\')' )
342+ return cb ( null , " require('" + newRequireArg + "')" )
302343 } else {
303344 return cb ( )
304345 }
305- } )
346+ }
347+ )
306348}
307349
308350function 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 ( )
315363}
0 commit comments