我想让我的非开发人员团队成员可以使用我的一个 Ruby 脚本(阅读“不愿设置和维护 Ruby 环境”)。
我们还使用了 Hubot在我们的团队中。
到现在为止,我相信你已经猜到了我的问题:“我如何编写一个可以调用我的 Ruby 脚本的 Hubot 脚本(CoffeeScript,即 JS)?”
ps:我的脚本需要一段时间才能完成,如果你们知道如何让我的 hubot 提供快速反馈(“我听到你的声音,我要运行你的脚本”)然后通知我什么时候脚本已完成(“您的脚本已成功完成”),那就太棒了。
最佳答案
我敢肯定,您现在可能已经弄明白了,但由于这个问题对我有帮助,我可以摆脱 Sean 的回答并完成这个谜题。
module.exports = (robot) ->
robot.respond /your regex/i, (msg) ->
cp = require "child_process"
cp.exec "./path/from/root/to/ruby script", (error, stdout, stderr) ->
if error
msg.send "Sorry I encounted this error \n" + stderr
else
msg.send "Done. The output: \n" + stdout
希望对您有所帮助。
关于javascript - 如何使用 Hubot 运行异步 Ruby 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13803602/