nano-fs
Extended native file system library adopted for Promise object.
Native functions
See https://nodejs.org/dist/latest-v5.x/docs/api/fs.html. All callback functions returns Promise object instead of call callback
function.
Additional functions
listFiles(path[, regexp])
Resolve Promise object with Array
of all files pathes filtered by optional RegExp.
var fs = require('nano-fs');
fs.listFiles('./source').then(function (list) {
console.log(list);
});
Prints something like
[ "tet.jk", "a/file.txt", "a/fileaa" ]
writeTree(path, object)
Write objects tree to file system tree.
fs.writeTree('./test', {
folder_a: {
'file_a.txt': 'content',
'file_b.txt': 'content'
},
folder_b: {
},
'file_c.txt': 'content'
});
readTree(path)
Resolve a Promise with objects tree where folders will be objects contains files as strings.
fs.readTree(path).then(function (o) {
console.log(o);
});
mkpath(path[, mode])
copy(source_file_name, destination_file_name)
Copy file to another location. If destination path does not exists it will be created by mkpath() call.
remove(path)
Recursively remove folder. It can remove file too.
empty(folder_path)
Empty folder. Try it! :)