@@ -32,7 +32,8 @@ describe('deploy', function() {
3232 host : 'host' ,
3333 repo : 'repo' ,
3434 path : 'path' ,
35- ref : 'ref'
35+ ref : 'ref' ,
36+ 'post-deploy' : 'post-deploy' ,
3637 }
3738 }
3839 } )
@@ -145,7 +146,26 @@ describe('deploy', function() {
145146 echoData . repo . should . eql ( conf . staging . repo )
146147 echoData . path . should . eql ( path . resolve ( conf . staging . path ) )
147148 echoData . host . should . eql ( conf . staging . host )
148- done ( )
149+ echoData [ 'post-deploy' ] . should . eql ( conf . staging [ 'post-deploy' ] )
150+
151+ conf . staging . env = { a : 1 , b : 2 }
152+ deploy . deployForEnv ( conf , 'staging' , [ ] , function ( ) {
153+ spawnCalls . length . should . equal ( 2 )
154+ spawnCalls [ 1 ] [ 1 ] [ 1 ] . should . be . a . String
155+ echoData = JSON . parse ( spawnCalls [ 1 ] [ 1 ] [ 1 ] . match ( / ^ e c h o ' ( .+ ?) ' / ) [ 1 ] )
156+ echoData [ 'post-deploy' ] . should . eql (
157+ 'export A=1 B=2 && ' + conf . staging [ 'post-deploy' ]
158+ )
159+
160+ conf . staging [ 'post-deploy' ] = ''
161+ deploy . deployForEnv ( conf , 'staging' , [ ] , function ( ) {
162+ spawnCalls . length . should . equal ( 3 )
163+ spawnCalls [ 2 ] [ 1 ] [ 1 ] . should . be . a . String
164+ echoData = JSON . parse ( spawnCalls [ 2 ] [ 1 ] [ 1 ] . match ( / ^ e c h o ' ( .+ ?) ' / ) [ 1 ] )
165+ echoData [ 'post-deploy' ] . should . eql ( 'export A=1 B=2' )
166+ done ( )
167+ } )
168+ } )
149169 } )
150170 } )
151171
@@ -231,6 +251,7 @@ describe('deploy', function() {
231251 echoData . repo . should . eql ( conf . staging . repo )
232252 echoData . path . should . eql ( path . resolve ( conf . staging . path ) )
233253 echoData . host . should . eql ( hosts [ spawnCount ] )
254+ echoData [ 'post-deploy' ] . should . eql ( conf . staging [ 'post-deploy' ] )
234255
235256 spawnCount += 1
236257
@@ -245,6 +266,39 @@ describe('deploy', function() {
245266 } )
246267 } )
247268
269+ it ( 'echoes JSON blobs with customized host and env attributes' , function ( done ) {
270+ var spawnCount = 0
271+
272+ spawnNotifier . on ( 'spawned' , function ( proc ) {
273+ var pipeFrom = spawnCalls [ spawnCount ] [ 1 ] [ 1 ] . split ( / \s * \| \s * / ) [ 0 ]
274+ pipeFrom . should . be . ok
275+
276+ var echoJSON = pipeFrom . match ( / ^ e c h o ' ( .+ ?) ' / ) [ 1 ]
277+ echoJSON . should . be . ok
278+
279+ var echoData = JSON . parse ( echoJSON )
280+ echoData . should . be . an . Object
281+
282+ echoData . ref . should . eql ( conf . staging . ref )
283+ echoData . repo . should . eql ( conf . staging . repo )
284+ echoData . path . should . eql ( path . resolve ( conf . staging . path ) )
285+ echoData . host . should . eql ( hosts [ spawnCount ] )
286+ echoData [ 'post-deploy' ] . should . eql ( 'export A=1 B=2 && ' + conf . staging [ 'post-deploy' ] )
287+
288+ spawnCount += 1
289+
290+ process . nextTick ( function ( ) {
291+ proc . emit ( 'close' , 0 )
292+ } )
293+ } )
294+
295+ Object . assign ( conf . staging , { env : { a : 1 , b : 2 } } )
296+ deploy . deployForEnv ( conf , 'staging' , [ ] , function ( ) {
297+ spawnCount . should . eql ( 4 )
298+ done ( )
299+ } )
300+ } )
301+
248302 it ( 'invokes our callback with supplied argument arrays' , function ( done ) {
249303 var argsIn = [ 1 , 2 , 'three' , 'four' ]
250304 spawnNotifier . on ( 'spawned' , function ( proc ) {
0 commit comments