Skip to content
/ reflect Public

Reflect the contents of one directory to another. At the speed of light. ⚡

License

Notifications You must be signed in to change notification settings

alumna/reflect

Repository files navigation

reflect
Reflect the contents of one directory to another. At the speed of light. ⚡

Features

  • It does not depend on rsync
  • Asynchronous and super fast with files' stat cache
  • Extremely lightweight with no dependencies – 2.3kB!
  • Fully tested on Linux, Mac and Windows
  • Added copy-on-write support for file systems that support it (see COPYFILE_FICLONE)

Additionally, this module is delivered as:

Install

$ npm install @alumna/reflect

Usage

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/"

About

Reflect the contents of one directory to another. At the speed of light. ⚡

Resources

License

Stars

Watchers

Forks

Packages

No packages published