您的位置:首页 > Web前端 > Node.js

[置顶] 基于Node的文件夹分析工具,可转换成树状图,Json格式等

2018-03-08 10:44 411 查看

安装

npm install folder2some


使用例子

let FT = require('folder2some'),
dir = 'F://web//javascript';

let ft = new FT(dir,{
ignoreFolder: ['node_modules'],
getFile: true
})

console.log(ft.toTree())
console.log(ft.toJSON())
console.log(ft.toAnalysis())


输出可能如下 :

├─clone
│   └─cloner.js
├─es6
│   └─es6.js
├─filestype
│   ├─test.js
│   └─ft.js
├─gallery
│   ├─utils.js
│   ├─gallery.styl
│   └─gallery.js
├─zepto
│   ├─test
│   │   ├─test2
│   │   │   └─2.html
│   │   └─1.html
│   ├─test2
│   └─zepto.js
├─text.html
└─1.html


[
"1.html",
{
"clone": [
"cloner.js"
]
},
{
"es6": [
"es6.js"
]
},
{
"filestype": [
"ft.js",
"test.js"
]
},
{
"gallery": [
"gallery.js",
"gallery.styl"
4000
,
"utils.js"
]
},
"text.html",
{
"zepto": [
{
"test": [
"1.html",
{
"test2": [
"2.html"
]
}
]
},
{
"test2": []
},
"zepto.js"
]
}
]


{
"path": "F://web//javascript",
"totalSize": "85.56KB",
"totalCount": 12,
"extPercent": [
{
"ext": ".html",
"percent": "0.00",
"count": 4
},
{
"ext": ".js",
"percent": "99.04",
"count": 7
},
{
"ext": ".styl",
"percent": "0.96",
"count": 1
}
]
}


参数配置

ignore : Array
: 忽略统计的目录

generateFile: boolean
当为true时,会在本目录生成一个文件.

源代码

github: https://github.com/Lemonreds/folder2some/blob/master/lib/ft.js
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐