folder2some
folder2some is a simple util to convert folder into some structures(like JSON,Tree,Info).
Installation
npm install folder2some
Usage & Input
let ft = require('./ft.js'),
dir = 'F://web//javascript';
folder to tree
console.log( ft.toTree(dir) )
node test.js
input like :
├─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
folder to JSON
console.log( ft.toJson(dir) )
node test.js
input like :
[
"1.html",
{
"clone": [
"cloner.js"
]
},
{
"es6": [
"es6.js"
]
},
{
"filestype": [
"ft.js",
"test.js"
]
},
{
"gallery": [
"gallery.js",
"gallery.styl",
"utils.js"
]
},
"text.html",
{
"zepto": [
{
"test": [
"1.html",
{
"test2": [
"2.html"
]
}
]
},
{
"test2": []
},
"zepto.js"
]
}
]
folder analysis
console.log(ft.toAnalysis(dir))
node test.js
input like :
{
"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
}
]
}
About me
github: https://github.com/Lemonreds
e-mail: lemonreds@163.com