0.0.2 • Published 5 years ago

@fremango/dir-tree v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

dir-tree

Get a tree view of the directory structure.

screenshot

Install

yarn add global @fremango/dir-tree

#or
npm i -g @fremango/dir-tree

Usage

Cli

dir-tree <dir> [options]

Nodejs

const { dirTree, scanDir } = require("dir-tree");

const dir = scanDir({
  dir: "./"
});
console.log("dir for Object", JSON.stringfly(dir, null, 2));
const tree = dirTree({
  dir: "./"
});

console.log("Tree: ", tree);

Apis

scanDir

Scan the directory with the configured options, return directory struct object

scanDir(Options, callback)

return dirStruct

dirStruct

nametypedefaultdesc
namestring''directory name
isDirbooleanfalseis directory
pathstring''directory absolute path
childrendirStruct[][]if isDir is true, children is this directory's children directory

callback

custom the structure of each item

(itemStruct) => itemStruct

nametypedesc
itemStructdirStructdirectory's struct object

dirTree

return a tree view of the directory structure.

dirTree(options)

Options

deep

desc: Scan the depth of the directory, if it is 0, scan all directories and their subdirectories

type: number

default: 0

use in cli: -d <number> or --deep <number>

ignore

desc: Ignored directory

type: string[]

default: undefined

use in cli: -i "<dir>,<dir>,..." or --ignore "<dir>,<dir>,..."

noChild

desc: Don't scan subdirectories of this directory

type: string[]

default: undefined

use in cli: -n "<dir>,<dir>,..." or --noChild "<dir>,<dir>,..."

color

desc: Output color text

type: Boolean

default: true

use in cli: --no-color disabled color text