bose-cli
v1.0.0
Published
自定义node命令
Downloads
5
Readme
node自定义命令demo
此仓库是node自定义命令demo,可clone下去稍改下直接用
运行
- git clone https://github.com/aliarmo/node-command-demo
- npm i
- npm link
- 执行自定义命令,例如:bose s,bose r,更多命令请看bin/bose文件
自定义node命令简要步骤
- 推荐在项目目录下建立一个bin文件夹,bin文件夹下面新建一个文件,文件开头必须要是
#!/usr/bin/env node
- 引入commander包即可自定义命令,具体用法可参考这个项目bin/bose文件
- package.json文件里面加入如下配置
// bose就是你自定义命令的名称,bin/bose是你定义命令文件
"bin": {
"bose": "bin/bose"
},
本地调试
- 当前项目下,执行npm link即可访问你自定义的命令
- npm unlink,解除link
发布
- npm publish,发布了别人就可以通过安装你这个包使用你的命令了