- 使用 Node 按照传入的 JSON 创建一个目录结构,避免了繁琐的文件创建过程
- npm - generator-files
node-创建文件目录
希望达到的目的:传入指定格式的 JSON 数据,使用 Node 创建相应的文件夹和文件
JSON 格式
- 如果 KEY 不是 files,将使用 KEY 来作为创建文件夹的文件夹名称
- 如果 KEY 是 files,其值(数组或者字符串)将作为创建文件的依据
示例:
1 | { |
创建目录结构
这里使用 yargs 来接受命令行参数
generator_files.js
1 | onst yargs = require("yargs") |
使用方式
1 | node ./generator_files.js --path=./files_json --basepath=./ |