Skip to content

dir2json-把目录结构转成json文件方便放到服务器然后下载文件,不依赖其他模块

License

Notifications You must be signed in to change notification settings

loufq/node-dir2json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dir2json

Use 2 CLI

install globel

npm install dir2json-lite -g

use 2 output

dir2json path/to/dir

dir2json.json output sample

{
    "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": ""
}

Quick Examples

install

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://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);

ref

About

dir2json-把目录结构转成json文件方便放到服务器然后下载文件,不依赖其他模块

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published