Super tiny and useful file utils.
npm install easyfile --save
- Map some sync method as default name:
easyfile.exists = fs.existsSync;
easyfile.chmod = fs.chmodSync;
easyfile.chown = fs.chownSync;
easyfile.append = fs.appendeasyfileSync;
easyfile.stat = fs.statSync;
easyfile.read = fs.readeasyfileSync;
easyfile.readlink = fs.readlinkSync;
easyfile.readdir = fs.readdirSync;
easyfile.rename = fs.renameSync;
easyfile.rmdir = fs.rmdirSync;
easyfile.unlink = fs.unlinkSync;
mkdir
ismddirp
easyfile.mkdir('/newpath/newpath/newpath');
copy
support file and dir
easyfile.copy('fromfile', 'tofile');
easyfile.copy('fromdir', 'todir');
When copy dir, some file or sub directory not you want could be filter:
easyfile.copy('fromdir', 'todir', {
// only copy js file
filter: filepath => path.extname(filepath) === '.js'
})
write
could force write and backup
easyfile.write('tofile', data, {
force: true,
backup: true
});