j6m8
j6m8

Reputation: 2409

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 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?

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 for loop

Upvotes: 1

Views: 405

Answers (1)

j6m8
j6m8

Reputation: 2409

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

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.

Upvotes: 3

Related Questions