49
49
args = parser .parse_args ()
50
50
51
51
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
+
52
65
def debug_print (message ):
53
66
if args .debug :
54
67
print message
@@ -206,16 +219,17 @@ def notify_error(stage, error):
206
219
notify_error ('install' , C .output )
207
220
208
221
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 )
212
225
except subprocess .CalledProcessError , C :
213
226
notify_error ('build' , C .output )
214
227
215
228
if not args .dry_run :
216
229
syslog .syslog ("Build of {}: start sync" .format (name ))
217
230
# TODO log the message
218
231
if config ['remote' ]:
232
+ build_subdir = builder_info [config ['builder' ]]['build_subdir' ]
219
233
subprocess .call (['rsync' ,
220
234
'-e' ,
221
235
'ssh '
@@ -227,9 +241,14 @@ def notify_error(stage, error):
227
241
os .path .expanduser ('~/.ssh/{}_id.rsa' .format (name )),
228
242
'--delete-after' ,
229
243
'-rqavz' ,
230
- '%s/build/' % checkout_dir , config ['remote' ]])
244
+ '%s/%s/' % (checkout_dir , build_subdir ),
245
+ config ['remote' ]])
231
246
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' ])
233
252
syslog .syslog ("Build of {}: finish sync" .format (name ))
234
253
else :
235
254
syslog .syslog ("Build of {}: not syncing, dry-run" .format (name ))
0 commit comments