// RockUp
// Hooks -- Represent a event-based hook that can be run

var spawn = require('child_process').spawn;
var path = require('path');
var _ = require('underscore');

module.exports = Hook;

/**
 * Create an instance of a Hook.
 *
 * @param {String} event        Name of the event to which this hook is connected
 * @param {String} scriptPath   Path to the hook script file
 **/
function Hook (event, scriptPath) {
  this.event = event;
  this.scriptPath = scriptPath;
  this.scriptDir = path.dirname(scriptPath);
}

/**
 * Execute the hook script.
 *
 * @param {Array} args          (opt.) An array of CLI arguments to pass to script invocation
 * @param {Function} cb(err)    Callback function triggered at completion. Passed error upon
 *                              invocation failure or non-zero script exit.
 **/
Hook.prototype.run = function (args, cb) {
  var event = this.event;
  if ( _.isUndefined(cb) && _.isFunction(args) ) {
    cb = args;
    args = [];
  }
  if ( !_.isArray(args) )
    throw new Error(event+" hook must be invoked with Array of arguments");
  
  var script = spawn(this.scriptPath, args, { cwd: this.scriptDir, stdio: [process.stdin, process.stdout, process.stderr] });
  script.on('exit', function(code, signal) {
    if (code === 0)
      cb();
    else
      cb( new Error(event+" hook returned non-zero ("+code+") status") );
  });
  script.on('error', function(err) {
    cb(err);
  });
};

// TODO: Allow args to be passed to each hook script
// environment name
// ??
@@ -1077,16 +1077,79 @@
 s%22);%0A  %0A
+  console.log( (%22--- Hook %22+event+%22 Begin ---%22).yellow.bold );%0A
   var sc
@@ -1307,24 +1307,87 @@
 , signal) %7B%0A
+    console.log( (%22--- Hook %22+event+%22 End ---%22).yellow.bold );%0A
     if (code
@@ -1528,24 +1528,87 @@
 tion(err) %7B%0A
+    console.log( (%22--- Hook %22+event+%22 End ---%22).yellow.bold );%0A
     cb(err);

Add visual barriers around hook script output