I have a Hubot instance running on an IRC. Inside my scripts directory, I have several coffeescripts linking to external python scripts. My issue is that I have data that should print out before other data within the external scripts such as "Processing request. Please wait..." etc and Hubot waits for the entire script to completely finish executing and dumps the output the IRC at once.
How do I modify my coffeescripts to send over output from an external script as it is received?
coffeescript example:
# Commands:
# Hubot jira-add-comment <ticket> "comment" - Add given comment to a JIRA ticket
{spawn} = require 'child_process'
module.exports = (robot) ->
addComment = (msg,ticket,comment) ->
output = spawn "/path/to/externalscript.py", [ticket,comment]
output.stdout.on 'data', (data) ->
msg.send data.toString()
robot.respond /jira-add-comment (\w+-\d+) (.+)$/i, (msg) ->
addComment(msg,msg.match[1].trim(),msg.match[2])
Thanks!