Reputation: 65
I realize this is kind of a silly question, but I'm deeply curious about how I accomplish the following.
I created a shell script for my cohort at school which builds out large project templates. I've successfully published the package to npm, but after downloading, I can't get the script to run. I'd like for users to simply download the package and run something like $ npm project-template start
(as an example) to trigger the script.
Is this possible?
If anyone has advice, suggestions, pointers, I'd really appreciate it. Thanks in advance!
Upvotes: 1
Views: 815
Reputation: 65
Its always after I ask the internet for answers that I find the answers on my own.
bin
aries objectBasically, what I needed to do was to add the command I wanted to run to the bin
section of the package.json
:
"bin": {
"nameOfCommand": "path/to/script.sh"
}
The left side, nameOfCommand
, is the name of the command that is used in your terminal
$ nameOfCommand args --options
The right side is the path to your CLI program, in this case, a bash/shell script.
The information can be found here in this article by NPM.
Upvotes: 3