fs.extra
Extra file utilities for node.js
Includes
copy
copyRecursive
mkdirp
move
walk
rmrf
Install
npm install --save fs.extra
Usage
// this will have all of a copy of the normal fs methods as wellvar fs = ;
fs.copy
Creates an fs.readStream
and fs.writeStream
and uses util.pump
to efficiently copy.
fs
Options are optional. replace
defaults to false, but will replace existing files if set to true
.
fs.copyRecursive
Basically a local rsync
, uses fs.copy
to recursively copy files and folders (with correct permissions).
fs
fs.mkdirRecursive
Included from https://github.com/substack/node-mkdirp
// fs.mkdirp(path, mode=(0777 & (~process.umask())), cb); fs;
fs.mkdirRecursiveSync
Included from https://github.com/substack/node-mkdirp
// fs.mkdirpSync(path, mode=(0777 & (~process.umask()))); try fs; catche throw e;
fs.move
Attempts fs.rename
, then tries fs.copy
+ fs.unlink
before failing.
fs
fs.rmRecursive
Included from https://github.com/jprichardson/node-fs-extra
Recursively deletes a directory (like rm -rf
)
// fs.rmrf(dir, callback); fs;
fs.rmRecursiveSync
Included from https://github.com/jprichardson/node-fs-extra
Recursively deletes a directory (like rm -rf
)
// fs.rmrfSync(dir); fs;
fs.walk
See https://github.com/coolaj86/node-walk
var walker = fs ; // file, files, directory, directorieswalker;
Aliases and Backwards Compatibility
For the sake of backwards compatability, you can call the recursive functions with their names as such
fs.remove <- fs.rmRecursive <- fs.rmrf
fs.removeSync <- fs.rmRecursiveSync <- fs.rmrfSync
fs.mkdirRecursive <- fs.mkdirp
fs.mkdirRecursiveSync <- fs.mkdirpSync
License
Copyright AJ ONeal 2011-2015
This project is available under the MIT and Apache v2 licenses.