synchronizator
v3.0.1
Published
Applies all changes from source directory to destination directory
Downloads
22
Maintainers
Readme
Synchronizator
Description
This package is used for synchronizing two directories. All changes made to source directory will be applied to destination directory.
Usage
let Synchronizator = require('synchronizator');
let synchronizator = Synchronizator(
'/path/to/sourceDir',
'/path/to/destinationDir',
{
performInitialSync: true, //perform initial synchronization?
ignored: [ //path substrings to ignore
".git/",
"someDir/node_modules/",
"dirName/test.txt"
],
onInitCompleted: function() {
console.log("Init completed");
setInterval(() => {
console.log("Sync queue length: " + synchronizator.getSyncQueueLength());
}, 1000);
}
}
);
Ignored option
Before sync of an item, its path is checked for existence of ignored substrings.
Ignoring directories
When ignoring directories, always include trailing slash '/'. Because if there is a file without extension and with same name as ignored directory, it will be also ignored.
Caution
When a directory is ignored, all of its contents are also ignored.
Examples
Example 1: Ignore directory
ignored: [
"node_modules/"
]
Will match paths like this:
/node_modules
/project/node_modules
/project/someDir/node_modules
...
Example 2: Ignore file
ignored: [
"someFile.txt"
]
Will match paths like this:
/someFile.txt
/project/someFile.txt
/project/node_modules/someFile.txt
...
Example 3: Ignore file in specified directory
ignored: [
"someDir/someFile.txt"
]
Will match paths like this:
/project/someDir/someFile.txt
/project/subDir/someDir/someFile.txt
...
But won't match paths like this:
/someFile.txt
/project/someFile.txt
/project/someDir/subDir/someFile.txt
...