Comment on page
CLI command line tool
- create a
bin
folder, create a file called: 'my-cli'#!/usr/bin/env noderequire(__dirname+'/../dist/my-cli') - Update your package.json:
"files": [
"dist",
"bin"
],
"main": "./dist/index.js",
"bin": {
"my-cli": "./bin/my-cli"
},
- So the flow is:
- We tell package the bin file is in the
bin
folder - The bin file invokes the actual script in
dist
folder - We develop the script in
lib
folder and babel the source ('prepublish') todist
folder - To test locally on dev machinenpm link# then start using the cli version
- To publish internally, donpm version minor # update versionnpm pack # this will create the abc-1.0.0.tgz file# to install and usenpm install -g abc-1.0.0.tgz
Reference:
- to run, do
coffee make testName
-
Last modified 5yr ago