dir-fs-utils
is aiming to be a collection of the utility functions for directories build on top of the native fs
module.
npm i dir-fs-utils
Then anywhere in your code.
import { DirUtils } from 'dir-fs-utils`
or
const { DirUtils } = require('dir-fs-utils');
await DirUtils.getFolderSize(folder_path);
await DirUtils.listFolderContent(folder_path);
(1)
async listFolderContent(path: string): Promise<string[]> {}
This method will return an array with all the files in a folder.
If the provided path does not exist or is not accessible, then it will generate an error.
(2)
async getFolderSize(path: string): Promise<number> {}
This method will return the total size of a folder in bytes.
If the provided path does not exist or is not accessible, then it will generate an error.
(3)
async unwrap(folderPath: string, options?: UnwrapOptions): Promise<Map<string, string>>
export interface UnwrapOptions {
keepFolder?: boolean;
force?: boolean;
}
This method will open the contents of a folder. By default, it will remove the original folder and undo only files for which the destination path does not exist.
The returned value is a map that will contain all the files that failed to be unwrapped. If the size of the map is 0, then all the files were unwrapped successfully.
keepFolder?:boolean
- if this property is set to true, then the original folder will remain intact(files will not be deleted)force?:boolean
- if this property is set to true, then the destination of the unwrapped files will overwritten
Pull requests and stars are always welcome. Please check the guidelines.
Author - Stan Georgian
This project is licensed under the MIT License