13

有几种方法可以在 Ruby 脚本中运行 JavaScript。例如,经常使用 ExecJS 将 NPM 模块移植到 Ruby。那么,是否有适用于 Node 的“ExecRuby”?

4

1 回答 1

18

您可以像使用任何其他 shell 命令一样调用 Rubychild_process.exec()

var exec = require("child_process").exec;

exec('ruby -e "puts \'Hello from Ruby!\'"', function (err, stdout, stderr) {
    console.log(stdout);
});

不知道是不是你要找的?

于 2011-11-12T00:14:16.020 回答