当前位置:网站首页>more-copy. JS specifies that the file template is generated to the specified file directory
more-copy. JS specifies that the file template is generated to the specified file directory
2022-06-12 20:01:00 【Pengshiyu】
more-copy.js
The specified file template is generated to the specified file directory
install
# Global installation is recommended
npm i more-copy -g
Use
1、 Command line
$ mcp [ Template path ] [ The output path ] [-p json character string ] [-c Profile path ]
eg:
$ mcp template.js demo.js
Parameters
-c Specify the profile path The default is ./more-copy.config.js
-p Pass in the parameter , receive json Format string
2、 user designation codes
const {
renderToFile } = require('more-copy');
renderToFile({
input, output });
Templates
Template rendering based on Nunjuck.js, The implication , Support Nunjuck.js All template syntax for
https://nunjucks.bootcss.com/templating.html
Command line
Usually , The file generation path of a project is fixed , Can combine package.json perhaps make Simplify the command line
To configure
The current directory can be configured more-copy.config.js
// Plug in Example
const {
MkdirPlugin, ParsePlugin, TimePlugin } = require('more-copy');
// Use custom plug-ins
const CustomPlugin = require('./custom-plugin.js');
module.exports = {
// Open the debug
debug: true,
// The use of plug-in , In order
plugins: [new CustomPlugin()],
};
The plug-in has been implemented
Users can use plug-ins to give options Add parameter
The plug-in contract adds options Properties on objects , Name the plug-in , Except for special .
for example : Use ParsePlugin Attributes will be added options.parse
// Plug in base class , Custom plug-ins are recommended to inherit this base class , And implement its method
Plugin(options);
// 1、 Create target folder recursively
MkdirPlugin();
// 2、 Change the naming style of the output file name , Support naming-style All style parameters of
// eg: {style: 'pascal'}
OutputNamingPlugin({
style });
// 3、 Resolve path parameters
ParsePlugin();
// 4、ThinkPHP Required parameters
// Support additional parameters -p '{"name": "table_name"}'
ThinkphpPlugin({
prefix: ' Table prefix ' });
// 5、 Time plug in
TimePlugin();
// 6、Vue Required parameters
// Support additional parameters -p '{"name": "name"}'
VuePlugin();
// 7、 from MySQL Query data in
// -p '{sql, data}'
MySQLPlugin({
config
});
// 8、 from MySQL Query table data in
// -p '{table}'
TablePlugin({
config
});
// 9、 Change the naming style of the output folder , Support naming-style All style parameters of
OutputDirnameNamingPlugin({
style})
Custom plug in
custom-plugin.js Used to process template input parameters
const Plugin = require('more-copy');
class CustomPlugin extends Plugin {
process_options(options) {
options.custom = {
name: 'Tom',
};
return options;
}
}
module.exports = CustomPlugin;
边栏推荐
- Centos7 installing PHP
- Optimization of SQL statements
- Dynamic memory management
- In 2022, 20 cities with the largest number of college students in China
- What is a hash index?
- Compilation of programs
- Pyinstaller packaging tutorial packaging resource files
- 华尔街备忘单(Wall Street Cheat Sheet)
- The latest Ningxia construction safety officer simulation question bank and answers in 2022
- MySQL installation and Application
猜你喜欢

Process accounting, process time, daemon

基于微信电子书阅读小程序毕业设计毕设作品(1)开发概要

Wechat e-book reading applet graduation design completion works (8) graduation design thesis template

WordPress optimization tutorial makes WordPress open faster

The latest Ningxia construction safety officer simulation question bank and answers in 2022

Understand Jack Dorsey's web5 from the ppt on page 16

解释器文件

Equipment management - borrowing and returning module 1

Detailed explanation of search tree and hash table

Demand and business model analysis-3-design
随机推荐
Wechat e-book reading applet graduation design completion works (8) graduation design thesis template
模塊八作業
In 2022, 20 cities with the largest number of college students in China
基于微信电子书阅读小程序毕业设计毕设作品(6)开题答辩PPT
EFCore调优
How to make a computer installation and startup USB flash disk
Experience Technology Department of ant group launched the 2023rd school recruitment
6 R factor and judgment Na
Basic structure of arithmetic unit
Ctfshow-web265 (deserialization)
What is a hash index?
测试必备:推荐一款跨平台App性能专项测试工具!
Detailed explanation of SQL exists usage
进程的创建fork()、消亡wait()
Programming tool download address
进程会计、进程时间、守护进程
2022年,中国大学生最多的20个城市
Unsupported class file major version 60
Demand and business model innovation-4-strategy
First build green, then build city