4949args = parser .parse_args ()
5050
5151
52+ builder_info = {
53+ 'middleman' : {
54+ 'build_command' : ['bundle' , 'exec' , 'middleman' , 'build' , '--verbose' ],
55+ 'build_subdir' : 'build' ,
56+ 'deploy_command' : ['bundle' , 'exec' , 'middleman' , 'deploy' ]
57+ },
58+ 'jekyll' : {
59+ 'build_command' : ['bundle' , 'exec' , 'jekyll' , 'build' , '--incremental' , '--verbose' , '--trace' ],
60+ 'build_subdir' : '_site' ,
61+ 'deploy_command' : None
62+ }
63+ }
64+
5265def debug_print (message ):
5366 if args .debug :
5467 print message
@@ -206,16 +219,17 @@ def notify_error(stage, error):
206219 notify_error ('install' , C .output )
207220
208221 try :
209- syslog . syslog ( "Build of {}: bundle exec middleman build" . format ( name ))
210- result = subprocess . check_output ([ 'bundle' , 'exec' , 'middleman' ,
211- 'build' , '--verbose' ] )
222+ command = builder_info [ config [ 'builder' ]][ 'build_command' ]
223+ syslog . syslog ( "Build of {}: {}" . format ( name , ' ' . join ( command )))
224+ result = subprocess . check_output ( command )
212225 except subprocess .CalledProcessError , C :
213226 notify_error ('build' , C .output )
214227
215228if not args .dry_run :
216229 syslog .syslog ("Build of {}: start sync" .format (name ))
217230 # TODO log the message
218231 if config ['remote' ]:
232+ build_subdir = builder_info [config ['builder' ]]['build_subdir' ]
219233 subprocess .call (['rsync' ,
220234 '-e' ,
221235 'ssh '
@@ -227,9 +241,14 @@ def notify_error(stage, error):
227241 os .path .expanduser ('~/.ssh/{}_id.rsa' .format (name )),
228242 '--delete-after' ,
229243 '-rqavz' ,
230- '%s/build/' % checkout_dir , config ['remote' ]])
244+ '%s/%s/' % (checkout_dir , build_subdir ),
245+ config ['remote' ]])
231246 else :
232- subprocess .call (['bundle' , 'exec' , 'middleman' , 'deploy' ])
247+ command = builder_info [config ['builder' ]]['deploy_command' ]
248+ if command :
249+ subprocess .call (command )
250+ else :
251+ notify_error ('deploy' , "builder '%s' does not possess a deploy method" % config ['builder' ])
233252 syslog .syslog ("Build of {}: finish sync" .format (name ))
234253else :
235254 syslog .syslog ("Build of {}: not syncing, dry-run" .format (name ))
0 commit comments