@bevry/fs-tree
Version:
Read and write to the filesystem as a tree, useful for quick scaffolding and comparisons of filesystem directories
15 lines • 959 B
TypeScript
/// <reference types="node" />
import type { WriteFileOptions } from 'fs';
import { ResultEncoding, Tree as ScanTree, Options } from 'scandirectory';
/**
* A tree for reading and writing.
* @example if Encoding is `utf8` then `{ [basename: string]: string | Tree }`
* @example if Encoding is `binary` then `{ [basename: string]: Buffer | Tree }`
* @example if Encoding is `undefined` then `{ [basename: string]: true | Tree }`
*/
export type Tree<Encoding extends ResultEncoding = 'utf8'> = ScanTree<Encoding>;
/** Read a directory to a tree */
export declare function readTree<Encoding extends ResultEncoding = 'utf8'>(directory: string, opts?: Omit<Options<Encoding>, 'directory' | 'includeRoot'>): Promise<Tree<Encoding>>;
/** Write a tree to a directory */
export declare function writeTree<Encoding extends ResultEncoding = 'utf8'>(directory: string, tree: Tree<Encoding>, opts?: WriteFileOptions): Promise<void>;
//# sourceMappingURL=index.d.ts.map