@@ -27,8 +27,6 @@ var uglify = require('gulp-uglify');
27
27
var concat = require ( 'gulp-concat' ) ;
28
28
var gutil = require ( 'gulp-util' ) ;
29
29
var download = require ( "gulp-download" ) ;
30
- var gunzip = require ( 'gulp-gunzip' ) ;
31
- var untar = require ( 'gulp-untar2' ) ;
32
30
var shell = require ( 'gulp-shell' ) ;
33
31
var jasmine = require ( 'gulp-jasmine' ) ;
34
32
var jasmineBrowser = require ( 'gulp-jasmine-browser' ) ;
@@ -39,6 +37,9 @@ var watch = require('gulp-watch');
39
37
var batch = require ( 'gulp-batch' ) ;
40
38
var fs = require ( "fs" ) ;
41
39
var runSequence = require ( 'run-sequence' ) ;
40
+ var path = require ( 'path' ) ;
41
+ var childProcess = require ( "child_process" ) ;
42
+ var decompress = require ( 'gulp-decompress' ) ;
42
43
43
44
gulp . task ( 'default' , [ "test" ] ) ;
44
45
@@ -131,15 +132,6 @@ gulp.task('test', function(cb){
131
132
runSequence ( 'test-nodejs' , 'test-browser' , cb ) ;
132
133
} ) ;
133
134
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
-
143
135
gulp . task ( 'test-nodejs' , [ 'nodejs' ] , function ( ) {
144
136
return gulp . src ( 'test/**/*.test.js' )
145
137
. pipe ( jasmine ( {
@@ -167,12 +159,62 @@ gulp.task('watch', function () {
167
159
} ) ) ;
168
160
} ) ;
169
161
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
+
170
167
gulp . task ( 'download-neo4j' , function ( ) {
171
- if ( ! fs . existsSync ( './build/neo4j-enterprise-3.0.0-alpha' ) ) {
168
+ if ( ! fs . existsSync ( neo4jHome ) ) {
172
169
// 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
+ ] )
177
219
}
178
220
} ) ;
0 commit comments