README.md自动生成目录
快速上手
sh
// 目录由 tree-node-cli 生成
npm i tree-node-cli -g
tree -L 4 -I "node_modules" > dir.md
几个文件目录树生成工具
- treer
- tree-cli
- tree-node-cli (推荐)
工具 | star | 最后更新时间 | 版本号 |
---|---|---|---|
treer | 95 | 2021-12-21 | 1.0.4 |
tree-cli | 237 | 2021-12-19 | 0.6.7 |
tree-node-cli | 222 | 2022-10-26 | 1.6.0 |
tree-cli 参考:https://www.npmjs.com/package/tree-cli
treer 参考: https://www.npmjs.com/package/treer
tree-node-cli 参考: https://www.npmjs.com/package/tree-node-cli
treer
缺陷:格式固定,参数顺序前后顺序不可随意调换,不能选择目录层级
shell
npm install treer -g
如果去掉js,可以利用正则表达式,如
shell
treer -e README.md -i /.js/
text
$ treer --help
Usage: treer [options]
Options:
-h, --help output usage information
-V, --version output the version number
-d, --directory [dir] Please specify a directory to generate structure tree
-i, --ignore [ig] You can ignore specific directory name
-e, --export [epath] export into file
tree-cli (推荐)
注意:如果你之前安装了 tree-node-cli,而现在又继续安装 tree-cli,现在安装的会覆盖之前安装的, 避免命令的冲突,可以先卸载之前的 tree-node-cli,使用的命令是: npm uninstall -g tree-node-cli,反过来也是一样
使用示例:
text
tree -l 3 -o out.txt -d --ignore 'node_modules/'
text
--help: outputs a verbose usage listing.
--version: outputs the version of tree-cli.
--debug: show debug info.
--fullpath: prints the full path prefix for each file.
--ignore: ignores directory or file you specify - accepts arrays as comma-delimited strings: 'node_modules/, .git/, .gitignore'
--link: follows symbolic links if they point to directories, as if they were directories. Symbolic links that will result in recursion are avoided when detected.
--noreport: omits printing of the file and directory report at the end of the tree listing and omits printing the tree on console.
--base: specify a root directory. Relative path from cwd root and absolute path are both acceptable. This argument is optional.
-a: all files are printed. By default tree does not print hidden files (those beginning with a dot '.'). In no event does tree print the file system constructs '.' (current directory) and '..' (previous directory).
-d: list directories only.
-f: append a '/' for directories, a '=' for socket files and a '|' for FIFOs.
-i: makes tree not print the indentation lines, useful when used in conjunction with the -f option.
-l: max display depth of the directory tree.
-o: send output to filename.
tree-node-cli (推荐)
全局安装:
sh
npm install -g tree-node-cli
使用示例:
text
tree -L 3 -I "node_modules" > tree.md
Mac: tree -L 2 -I "node_modules" -r -F
Win: treee -L 2 -I "node_modules" -r -F
遍历三层目录结构,忽略node_modules,输出到tree.md
Note: Use the command treee on Windows and Linux to avoid conflicts with built-in tree command.
text
$ tree -h
Usage: tree [options]
Options:
-V, --version output the version number
-a, --all-files All files, include hidden files, are printed.
--dirs-first List directories before files.
-d, --dirs-only List directories only.
-s, --sizes Show filesizes.
-I, --exclude [patterns] Exclude files that match the pattern. | separates alternate patterns. Wrap your entire pattern in double quotes. E.g. `"node_modules|coverage".
-L, --max-depth <n> Max display depth of the directory tree.
-r, --reverse Sort the output in reverse alphabetic order.
-F, --trailing-slash Append a '/' for directories.
-S, --line-ascii Turn on ASCII line graphics.
-h, --help output usage information
Contributors
作者:Long Mo
字数统计:683 字
阅读时长:3 分钟
文章作者:Long Mo
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Longmo Docs !