Reputation: 3153
I have a designed a Node application which is based on yeoman
which I want it to distribute it to the user using npm.
The thing is after installing the application using node. I want to user to provide several global commands through which he can have ease using my application easily just like command are provided when using grunt
or bower
or yeoman
.
$ bower install <package-name>
$ grunt serve
Similarly I want my application to provide some command so that user can have ease to handle it. let the command be xyz
$ xyz init #will initialize the application and create the scaffolding.
I already have the application designed on node
I just want it to provide
the application installation using a global command line.
Upvotes: 0
Views: 74
Reputation: 19337
Just create a bin script :
package.json :
"bin": {
"xyz": "index.js"
}
index.js :
console.log(process.argv);
Usage :
npm install xyz
xyz foo bar
Outputs :
[ 'node', '/path/to/your/script/file', 'foo', 'bar']
For more information, you can refer to this blog post : Building a simple command line tool with npm
Upvotes: 2