file-manager-js
Description
It uses node filesystem to manage files and directories on the local storage through an enhanced promise interface. It can list/create/remove files and directories recursively with promises.
Install
npm install file-manager-js
Usage
// require all functionsconst fileManager = ; // OR specific functionsconst list removeFile rename = ;
.stat(path)
promisified fs.stat. retrieves the stats of a file or directory. https://nodejs.org/api/fs.html#fs_class_fs_stats
fileManager
.info(path)
returns an extended stats object that includes size (bytes) and type of the path
// file infofileManager
.join(path1, path2)
join two paths. a delegate to require('path').join
let p = fileManager; // a/b/c/d/e/f
.list(path)
list first-level files and directories inside a directory
// path can be an absolute path using __dirnamefileManager
.listDeep(path)
list in-depth files and directories inside a directory
fileManager
.exists(path)
checks if a path (file or directory) exists and resolve with true or false
fileManager
.createDir(path)
creates a single directory or a directory tree
// create a directory treefileManager
.createFile(path)
creates a file and creates the directory tree in the path if not exists
// creates a directory structure then the filefileManager
.readFile(path)
reads entire file content
fileManager
.removeDir(path)
removes a directory or directory tree with all its content
// remvove a/b/c/d + a/b/c + a/b/test.txt + a/b + afileManager
.removeFile(path)
removes a file
// removed ./test.txtfileManager
.rename(oldPath, newPath)
rename a file or directory
// rename file ./test.txt to ./ttt.txtfileManager
Build
grunt build
License
The MIT License. Full License is here