up-fs
v0.0.1
Published
git remote add origin [email protected]:theajack/up-fs.git
Downloads
2
Readme
Up-fs
This makes it easier to use the node-fs module
Feature
- All directories that don't exist are taken into account
- You can delete entire folders and all subfiles
- Copy the entire catalog and its contents
- Set the base directory for the reference
- Deeply traverse the folder
- Other convenient APIs
Install & Use
npm i up-fs
const fs = require('up-fs');
declaration
declare class UpFS {
setDir(dir: string): void;
rename(filePath: string, newName: string): void;
resolve(filepath: string): string;
exist(dirPath: string): boolean;
clearDir(dirPath: string, removeSelf?: boolean): void;
removeDir(dirPath: string): void;
removeFile(filePath: string): void;
createDir(dirPath: string): void;
createFile(filePath: string): void;
ensureDir(dirPath: string): void;
copyFile({ src, target, handler }: {
src: string;
target: string;
handler?: (content: string) => string;
}): void;
handleJson<Json extends IJson = IJson>(content: string, handler: (data: Json) => IJson): string;
copyDir({ src, target, filter, handler }: {
src: string;
target: string;
filter?: ((name: string) => boolean);
handler?: (content: string) => string;
}): void;
readFile(filePath: string): string;
writeFile(filePath: string, content: string): void;
readDir(dirPath: string): string[];
traverseDir(dirPath: string, callback: (filepath: string, isDir: boolean) => void, dirFirst?: boolean): void;
}