j6m8 j6m8 - 4 years ago 215
Bash Question

How can I pipe a command into the meteor shell?

Let's say I have a few directories, each running a different branch of a Meteor development server. I could

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?

Is there some equivalent of

meteor shell < 'DoJSThing()`

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] source for bash

Answer Source

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

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

$ meteor shell < myfile

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download