0

I'm working on a node package which has an installation script to set up a simple application structure. It's not doing anything too strenuous, just creating a few folders and creating an "admin" user if one doesn't exist.

At the moment it's doing a bunch of checks every time the application starts and does the setup process if required. Is there any way of doing it through the command line? Something along the lines of the user just typing my-package install or npm run my-package-install to call the script?

1 Answer 1

4

yes, with npm, you can build a simple commandline tool.

And you can define/parse the args from terminal.

You need to define the script you want to run in your package.json.

"bin": {
    "your-command": "bin/commit.js"
}

And run npm link, this would make the command available.

For more detail, check Building a simple command line to with npm

Hope this can answer your question. : )

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, that was the missing step. I was looking at commander but couldn't figure out how to actually make the command available. I also had to run npm link in the project folder again to make the command available. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.