npm install dir2json-lite -gdir2json path/to/dir{
"path": "path/to/dir",
"name": "folder2json",
"type": "folder",
"children": [
{
"path": "/bin",
"name": "bin",
"type": "folder",
"children": [
{
"path": "/bin/index.js",
"name": "index.js",
"type": "file"
}
]
},
{
"path": "/package.json",
"name": "package.json",
"type": "file"
}
],
"baseUrl": ""
}npm install dir2json-lite --save//indclude core
var dir2json = require('dir2json-lite');
var input = process.argv[2];
if (!input) {
return console.log('must given dir path.');
}
//init
var f2j = new dir2json();
f2j.rootDir = input;
f2j.baseUrl = 'http://www.github.com';
f2j.ignores = ['node_modules'];//ignore folder
//get JSON Object
var jsonObj = f2j.dir();
console.log(jsonObj);
//save file
var savePath = f2j.save();
console.log('Done!SavePath:' + savePath);