我想了解为什么我的代码未将stdout
传递给taskList
,childp.exec
内msg.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
有什么建议吗?