This article mainly introduces you to the tutorial on how to use node to create your own command line tool. It is mainly shared with you in the form of graphic and text code. I hope it can help you.
1. Implement a simple function
##2. Environment
1. System: window 102. Editor: vscode
3.node version: 8.7.0
三, Start playing
1. Open the command line and create a new pa'ckage.json1 |
|
##
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
1 |
|
1 |
|
It is successful if hello world is printed correctly
6. Realize the preview effect
The principle is that when executing cli.js, it will read the template you set, then generate a file in the current directory,
Write the content of the template, simple The code is as follows
1 2 3 4 5 6 7 8 9 10 |
|
Related recommendations:
Using command line tools in PHP_PHP tutorialThe above is the detailed content of How to create your own command line tool for node. For more information, please follow other related articles on the PHP Chinese website!