2 tree-cli 的使用方法

上一小节,我们安装了 tree-cli,是为了方便生成项目树,查看当前目录结构的。

如上小节代码 package.json中的配置

json 复制代码
  "scripts": {
    "tree": "treee -a -l 4 --ignore 'node_modules, dist, .git' --directoryFirst -f"
  },

快速使用

bash 复制代码
# 查看当前项目目录树(默认 4 层深度,忽略 node_modules 等)
pnpm tree

常用命令

bash 复制代码
# 基础用法 - 列出所有文件和目录
pnpm tree

# 只显示目录结构(不显示文件)
npx treee -d --ignore 'node_modules, dist, .git'

# 控制显示深度(-l 指定层数)
npx treee -l 2 --ignore 'node_modules, dist, .git'
npx treee -l 6 --ignore 'node_modules, dist, .git'

# 输出到文件(-o 指定输出文件)
npx treee -l 4 --ignore 'node_modules, dist, .git' -o docs/tree-output.txt

# 显示隐藏文件(-a)
npx treee -a --ignore 'node_modules, dist, .git'

# 目录优先排列 + 标记文件类型(-f 在目录后加 /)
npx treee --directoryFirst -f --ignore 'node_modules, dist, .git'

# 忽略更多目录
npx treee --ignore 'node_modules, dist, .git, coverage, .pnpm-store'

# 不显示统计报告
npx treee --noreport --ignore 'node_modules, dist, .git'

参数说明

参数 说明
-l <n> 最大显示深度
-d 只显示目录
-f 目录后加 /,socket 文件加 =,FIFO 加 `
-a 显示隐藏文件(以 . 开头的文件)
-o <file> 输出到指定文件
--ignore '<dirs>' 忽略指定目录/文件,逗号分隔
--base <path> 指定根目录
--directoryFirst 目录排在文件前面
--noreport 不打印末尾的统计信息
--fullpath 显示完整路径
相关推荐
胡萝卜术12 小时前
从API调用到手写LRU:力扣146「LRU缓存」的哈希表+双向链表终极进化之路
前端·javascript·面试
科技道人12 小时前
记录 默认置灰/禁用 app ‘Search Engine Selector‘ 的disable按钮
开发语言·前端·javascript
天疆说12 小时前
Zotero Connector 在 Edge 里找不到桌面 Zotero(Linux / Zotero 9.0.6 / Edge 150)
linux·前端·edge
李伟_Li慢慢14 小时前
02-从硬件说起WebGL
前端·three.js
kyriewen15 小时前
看了微软几万人用AI编程的数据——效率涨24%的代价没人提
前端·ai编程·claude
2601_9637713715 小时前
How to Scale Your WordPress Store Traffic in 2026
前端·php·plugin
亿元程序员15 小时前
老板说我的3D箭头游戏用来做试玩太普通了,没人想玩,让我变点花样...
前端
李伟_Li慢慢15 小时前
01-threejs架构原理-课程简介
前端·three.js
_瑞17 小时前
深入理解 iOS 渲染原理
前端·ios
IT_陈寒17 小时前
SpringBoot自动配置失灵?你可能忘了这个关键注解
前端·人工智能·后端