反映一个目录的内容到另一个目录。 以出光速为相. 赞:
特征
- 这个 没有 取决于
rsync - 与文件同步和超快"
stat缓存 - 极轻重量 无依赖关系 -2.3克贝!
- 在 Linux 、 Mac 和 Windows 上全面测试
- 为支持它的文件系统添加了副本并写入支持(参见 缔约方会议(中文(简体) )
此外,本单元是:
- ES 模块数字 :
dist/reflect.es.js - 常见JS数字 :
dist/reflect.cjs.js
安装
$ npm install @alumna/reflect
使用量
import reflect from '@alumna/reflect';
let { res, err } = await reflect({
src: 'src/',
dest: 'dest/',
// (OPTIONAL) Default to 'true'
recursive: true,
// (OPTIONAL) Default to 'true'
// Delete in dest the non-existent files in src
delete: true,
// (OPTIONAL)
// Array with files and folders not to reflect
exclude: [ "skip-this-file.txt", "skip/this/directory" ],
// (OPTIONAL)
// Seconds of time to sync with (for example, 7200, only sync last 2 hours of changes)
modified_within: null,
// (OPTIONAL)
// Only sync files that are newer in the source (ie, destination files that have been updated won't be overwritten)
only_newer: false,
// (OPTIONAL)
// Disable COPYFILE_FICLONE if supported by file system, see more info:
// https://nodejs.org/docs/latest-v17.x/api/fs.html#fscopyfilesrc-dest-mode-callback
file_clone: true,
});
if ( err )
console.error( err )
else
console.log( res ) // Directory "src/" reflected to "dest/"