Creating a command line command with a Meteor package or npm package

Hi Meteor People,

I trying to find a way to create a new command for the command line inside a meteor app. I’ve created a few bash scripts that I use in all my Meteor apps and I’d like to package them in a way that’s usable for everyone.

Right now, I copy my scripts into /private/bash and I run scripts like this:

./private/bash/my-bash-script-here

Is there a way to wrap this in a package make this either:

meteor my-bash-script

or

meteor npm my-bash-script

or something like that?

I may be misinterpreting your request here, but I don’t think Meteor is suitable for packaging bash scripts at all. What I think you want is to allow anyone to easily access your scripts, but I don’t think there is a standard way, with or without Meteor.

Personally I prefer to do scripting in nodejs. For one it’s the same language I use on the front end, server and utility scripts, so I can share functions across my whole stack. There are also plenty of node_modules that can make development quicker for you.

But there is another important benefit: you can publish node modules as command line utilities. See my repo GitHub - mikkelking/askmike: Command line utilities to get useful information (starting with ip address) as an example. There are not many utilities in it, but you’ll get the idea.

If you have nodejs installed on your machine, you can try it out with this command:

npx askmike ip

npx: installed 86 in 13.233s
IP Addresses:
en1: 192.168.1.109

It will “install” it on your system (which takes a moment), and the next time you run it, it will verify the version, and run the cached version (if it hasn’t changed).

You’ll need a github account, and also an npm account, so that you can publish your module. Have a play with it. (You are welcome to fork my repo and contribute back too :slight_smile: )

1 Like

Hi mikkelking!

I like your approach. I think it will allow me to do what I want. I’ll let you know once it’s done.