如何将命令通过管道传输到流星壳? [英] How can I pipe a command into the meteor shell?

查看:41
本文介绍了如何将命令通过管道传输到流星壳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有几个目录,每个目录运行 Meteor 开发服务器的不同分支.我可以cd到每个目录,运行meteor shell,然后输入命令.这对于 2 或 3 个目录非常有用,但是如果我有 10 个呢?100?

Let's say I have a few directories, each running a different branch of a Meteor development server. I could cd to each directory, run meteor shell, and type a command. And that's great for 2 or 3 directories, but what if I have 10? 100?

有什么等价的

meteor shell < 'DoJSThing()`

我可以从命令行编写脚本,以便我可以使用[1]

that I can script from the command line, so that I can use[1]

for d in ./*/ ; do (cd "$d" && meteor shell "doJSThing()" ); done

<小时>

[1] bash for 循环的源代码

推荐答案

在最新的 Meteor(我目前正在测试 1.3)上,您确实可以使用该拉取请求中提供的语法:

On the latest Meteor (I'm currently testing on 1.3), you can indeed use the syntax provided in that pull request:

$ echo Meteor.isServer | meteor shell
true

您也可以将 JS 写入文件并使用 < 语法通过管道输入标准输入:

You can also write your JS to a file and use the < syntax to pipe into stdin:

$ meteor shell < myfile

值得注意的是,如果您使用 .js 扩展名命名您的 JS 文件,它将自动加载到正在运行的 Meteor 应用程序中,这可能是您想要的,但可能不是.

It's worth noting that if you name your JS file with a .js extension, it'll auto-load into the running Meteor app, which is potentially, but probably not, what you want.

这篇关于如何将命令通过管道传输到流星壳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆