@jsvision/files / buildDirTree
Function: buildDirTree()
buildDirTree(
fs,currentPath):DirNode[]
Defined in: files/src/fs/tree.ts:72
Build the directory-tree rows for a current path: the ancestor chain from the root down to it, followed by its immediate subdirectories.
Parameters
fs
The filesystem to read through.
currentPath
string
The directory the tree is centred on (its subdirectories are listed).
Returns
DirNode[]
The ordered tree rows, top to bottom.
Example
ts
import { buildDirTree, nodeFileSystem } from '@jsvision/files';
const rows = buildDirTree(nodeFileSystem, '/home/user/project');
for (const r of rows) console.log(r.connector + r.label);
// → /
// └─┬home
// └─┬user
// └─┬project
// └──src