@@ -27,8 +27,6 @@ var uglify = require('gulp-uglify');
2727var concat = require ( 'gulp-concat' ) ;
2828var gutil = require ( 'gulp-util' ) ;
2929var download = require ( "gulp-download" ) ;
30- var gunzip = require ( 'gulp-gunzip' ) ;
31- var untar = require ( 'gulp-untar2' ) ;
3230var shell = require ( 'gulp-shell' ) ;
3331var jasmine = require ( 'gulp-jasmine' ) ;
3432var jasmineBrowser = require ( 'gulp-jasmine-browser' ) ;
@@ -39,6 +37,9 @@ var watch = require('gulp-watch');
3937var batch = require ( 'gulp-batch' ) ;
4038var fs = require ( "fs" ) ;
4139var runSequence = require ( 'run-sequence' ) ;
40+ var path = require ( 'path' ) ;
41+ var childProcess = require ( "child_process" ) ;
42+ var decompress = require ( 'gulp-decompress' ) ;
4243
4344gulp . task ( 'default' , [ "test" ] ) ;
4445
@@ -131,15 +132,6 @@ gulp.task('test', function(cb){
131132 runSequence ( 'test-nodejs' , 'test-browser' , cb ) ;
132133} ) ;
133134
134- gulp . task ( 'start-neo4j' , [ 'download-neo4j' ] , shell . task ( [
135- 'chmod +x build/neo4j-enterprise*/bin/neo4j' ,
136- 'build/neo4j-enterprise*/bin/neo4j start' ,
137- ] ) ) ;
138-
139- gulp . task ( 'stop-neo4j' , shell . task ( [
140- 'build/neo4j-enterprise*/bin/neo4j stop' ,
141- ] ) ) ;
142-
143135gulp . task ( 'test-nodejs' , [ 'nodejs' ] , function ( ) {
144136 return gulp . src ( 'test/**/*.test.js' )
145137 . pipe ( jasmine ( {
@@ -167,12 +159,62 @@ gulp.task('watch', function () {
167159 } ) ) ;
168160} ) ;
169161
162+ var neo4jLinuxUrl = 'http://alpha.neohq.net/dist/neo4j-enterprise-3.0.0-M01-NIGHTLY-unix.tar.gz' ;
163+ var neo4jWinUrl = 'http://alpha.neohq.net/dist/neo4j-enterprise-3.0.0-M01-NIGHTLY-windows.zip' ;
164+ var neo4jHome = './build/neo4j-enterprise-3.0.0-M01' ;
165+ var isWin = / ^ w i n / . test ( process . platform ) ;
166+
170167gulp . task ( 'download-neo4j' , function ( ) {
171- if ( ! fs . existsSync ( './build/neo4j-enterprise-3.0.0-alpha' ) ) {
168+ if ( ! fs . existsSync ( neo4jHome ) ) {
172169 // Need to download
173- return download ( "http://alpha.neohq.net/dist/neo4j-enterprise-3.0.0-M01-NIGHTLY-unix.tar.gz" )
174- . pipe ( gunzip ( ) )
175- . pipe ( untar ( ) )
176- . pipe ( gulp . dest ( './build' ) ) ;
170+ if ( isWin ) {
171+ return download ( neo4jWinUrl )
172+ . pipe ( decompress ( { strip : 1 } ) )
173+ . pipe ( gulp . dest ( neo4jHome ) ) ;
174+ }
175+ else {
176+ return download ( neo4jLinuxUrl )
177+ . pipe ( decompress ( { strip : 1 } ) )
178+ . pipe ( gulp . dest ( neo4jHome ) ) ;
179+ }
180+ }
181+ } ) ;
182+
183+ var runPowershell = function ( cmd ) {
184+ var spawn = childProcess . spawn , child ;
185+ child = spawn ( "powershell.exe" , [
186+ 'Import-Module ' + neo4jHome + '/bin/Neo4j-Management.psd1;' + cmd ] ) ;
187+ child . stdout . on ( "data" , function ( data ) {
188+ console . log ( "Powershell Data: " + data ) ;
189+ } ) ;
190+ child . stderr . on ( "data" , function ( data ) {
191+ console . log ( "Powershell Errors: " + data ) ;
192+ } ) ;
193+ child . on ( "exit" , function ( ) {
194+ console . log ( "Powershell Script finished" ) ;
195+ } ) ;
196+ child . stdin . end ( ) ; //end input
197+ }
198+
199+ gulp . task ( 'start-neo4j' , [ 'download-neo4j' ] , function ( ) {
200+ if ( isWin ) {
201+ runPowershell ( 'Install-Neo4jServer -Neo4jServer ' + neo4jHome + ' -Name neo4j-js;' +
202+ 'Start-Neo4jServer -Neo4jServer ' + neo4jHome + ' -ServiceName neo4j-js' ) ;
203+ } else {
204+ shell . task ( [
205+ 'chmod +x' + neo4jHome + 'bin/neo4j' ,
206+ neo4jHome + '/bin/neo4j start' ,
207+ ] ) ;
208+ }
209+ } ) ;
210+
211+ gulp . task ( 'stop-neo4j' , function ( ) {
212+ if ( isWin ) {
213+ runPowershell ( 'Stop-Neo4jServer -Neo4jServer ' + neo4jHome + ' -ServiceName neo4j-js;' +
214+ 'Uninstall-Neo4jServer -Neo4jServer ' + neo4jHome + ' -ServiceName neo4j-js' ) ;
215+ } else {
216+ shell . task ( [
217+ neo4jHome + '/bin/neo4j stop' ,
218+ ] )
177219 }
178220} ) ;
0 commit comments