An extended, promisified fs drop-in-replacement for Node.js >=7.6
Features
All asynchronous fs functions are and converted into promises with async-magic
Lot of extended functions are added
Designed to run with the pure power of native Promise, await and async function
No backward compatibility layer
OS Support for POSIX and Win Platforms (as of v1.3.0)
Streams, Streams, Streams - all file operations are stream-based!
Addons
copy Just copy a file (stream based)
bulkCopy Copy multiple files/directories in once
mkdirp Create directories recursivly
scandir List all files + directories of given directory recursivly
rmrf Removes all files of a given directory recursivly
exists Custom exists function to test file existence
isFile Check if item is a file
isDirectory Check if item is a directory
isSymlink Check if item is a symlink
isSocket Check if item is a socket
isFileOfType Check if item is of specific type
FileInputStream Open a new fileReadStream
FileOutputStream Write stream to destination file
untar Extracting .tar archives using tar-stream
untgz Extracting gzip compressed .tar archives
gzip Compress a file
gunzip Decompress a file
sha1file SHA1 File Checksum
sha256file SHA256 File Checksum
sha384file SHA384 File Checksum
sha512file SHA512 File Checksum
md5file MD5 File Checksum
checksum Generic File Checksum
statx Silent stat (returns false in case of ENOENT)
Promisified FS API
The following asynchronous fs methods are promisified and exposed within the fs-magic object. All synchronous functions are ignored because there is no need for them anymore - use await!
access
appendFile
chmod
chown
close
fchmod
fchown
fdatasync
fstat
fsync
ftruncate
futimes
lchown
link
lstat
mkdir
mkdtemp
open
read
readFile
readdir
readlink
realpath
rename
rmdir
stat
symlink
truncate
unlink
utimes
write
writeFile
General Usage
const _fsm = require('fs-magic');// wraper (async function(){ // get stats const stats= await _fsm.fstat('myfile.js'); // does the file exists ? console.log(await _fsm.exists('myfile.js')); // copy a file, set chmod to 0640 await _fsm.copy('test1.js', 'test2.js', 0o640); // create directory stucture at once await _fsm.mkdirp('my/custom/dir/1/2/3', 0o777, true);