From 1f181ee53a1747554d19726f32bc103ea455072c Mon Sep 17 00:00:00 2001 From: Riley Date: Sun, 22 Apr 2012 10:57:44 -0400 Subject: [PATCH] Enable custom build handler with command-line tool * command line tool uses configured or default build handler * bind configured build/rebuild handlers to Buildr instance --- bin/buildr.coffee | 3 +-- lib/buildr.coffee | 12 +++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/bin/buildr.coffee b/bin/buildr.coffee index e8f4d9f..cf76d4f 100755 --- a/bin/buildr.coffee +++ b/bin/buildr.coffee @@ -12,5 +12,4 @@ cwd = process.cwd() cson.parseFile "#{cwd}/buildr.cson", (err,config) -> throw err if err myBuildr = buildr.createInstance(config) - myBuildr.process (err) -> - throw err if err + myBuildr.process() diff --git a/lib/buildr.coffee b/lib/buildr.coffee index d9f964a..79173bb 100644 --- a/lib/buildr.coffee +++ b/lib/buildr.coffee @@ -100,18 +100,20 @@ class Buildr @config = tmp # Handlers - @config.buildHandler or= (err) => + @config.buildHandler or= (err) -> if err @log 'error', err throw err @log 'info', 'Building completed' - @config.successHandler.call(@) if @config.successHandler - @config.rebuildHandler or= (err) => + @config.successHandler.call(@) if @config.successHandler + @afterBuild = (err) => @config.buildHandler.call(@,err) + @config.rebuildHandler or= (err) -> if err @log 'error', err throw err @log 'info', 'ReBuilding completed' @config.successHandler.call(@) if @config.successHandler + @afterRebuild = (err) => @config.rebuildHandler.call(@,err) # Logger if @config.log is true then @config.log = 6 @@ -150,7 +152,7 @@ class Buildr # Prepare buildr = @ log = @log - next or= @config.rebuildHandler or @config.buildHandler + next or= @afterRebuild # Log log 'debug', 'Setting up watching...' @@ -186,7 +188,7 @@ class Buildr # Prepare log = @log - next or= @config.buildHandler + next or= @afterBuild # Log log 'info', 'Processing started'