没事写了一个针对Node.js 的文件树
发布于 7 年前 作者 yujintang 3865 次浏览 来自 分享

平时喜欢使用tree查看某个项目的目录结构,但是tree命令遇到node_modules,这个就很不友好了,然后自己撸了一个tree2,上效果 先上github地址:https://github.com/yujintang/tree2 untitled1.png

使用也很简单,API如下:

模仿linux tree

可以做到文件过滤,使其使用更方便

安装

$npm install tree2 -g

使用

$tree2 

show 某个文件夹下内容

$tree2 /xx/xx/x

查看常规Node.js 文件目录树

不展开node_modules, 同时进行配色

$tree2 -a

对文件树进行保存

将该文件树保存到该命令下的tree2.md

$tree2 -s

详细例子

如将/usr/local 下文件进行tree, 并且配色, 不展开 node_modules, go 两个文件夹下的内容, 最后保存

$tree2 -c -i go,node_modules -s /usr/local

具体用法

$tree2 -h 

里面主要用了commander和chalk,但是配色并不是太好看,有想法的同学们给点意见什么的啦,github地址在这:https://github.com/yujintang/tree2

4 回复

必须star啊,代码也挺规范

把autojump也重写了吧

@i5ting 谢老大star啦,这些小程序可以顺便练手的

这个可以有,必须 star 去了。

回到顶部