CoffeeScript将子进程结果传递给变量

时间:2014-10-30 00:46:18

标签: coffeescript

我想了解为什么我的代码未将stdout传递给taskListchildp.execmsg.send工作正常,但taskList始终为空字符串

cmd = "cd #{directory}; \
       bundle exec rake -T | perl -lne 'print if /^rake (clear|integration):/'"
taskList = ""
childp = require 'child_process'
childp.exec cmd, (error, stdout, stderr) =>
  if error?
    msg.send ":x: Error to get rake task lists"
    return
  else
    msg.send stdout # Works fine, I can see a list of rake tasks I want
    taskList = stdout

msg.send typeof taskList # Return 'string'
msg.send taskList        # empty string is sent back

有什么建议吗?

0 个答案:

没有答案