javascript - 如何使用 Hubot 运行异步 Ruby 脚本?

标签 javascript ruby node.js coffeescript hubot

我想让我的非开发人员团队成员可以使用我的一个 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/

相关文章:

javascript - Angular $broadcast 仅在页面刷新时填充数据

javascript - Grunt - 插件文件夹在构建 dist 后消失

ruby - 尝试 "git push heroku master"时出错

php - Cucumber响应对象——PHP环境

Node.js 驱动程序 "mongodb"findAndModify() 的实现 - 如何指定字段?

javascript - 在JavaScript中计算跳跃动画

javascript - 在 FabricJS 中删除多个路径

ruby - 在Neo4j.rb中设置 "friends"(双向关系)的正确方法

javascript - 如何在 Node 上使用 YUI3?

javascript - js中如何插入换行符?