TreeDiff Logo

File tree comparison and synchronization for Node.js!

Installation

$ npm install treediff

Instantiate like so:
var TreeDiff = require('treediff');
var treediff = new TreeDiff();

Features

Methods

.compare(mapA, mapB, callback)

Will compare one file location with another one.

Arguments

Example

var folderA = {
  type: 'local',
  path: 'path/to/folder-a'
};

var folderB = {
  type: 'local',
  path: 'path/to/folder-b'
};

treediff.compare(folderA, folderB, function(err, differences){
  // ...
});

.sync(mapA, mapB, callback)

Will apply the differences from mapB to mapA.

Arguments

Example

var folderA = {
  type: 'local',
  path: 'path/to/folder-a'
};

var folderB = {
  type: 'local',
  path: 'path/to/folder-b'
};

treediff.sync(folderA, folderB, function(err){
  // ...
});  

.registerFilter(filter)

Adds a filter to exlude entries from the comparison process. The filter will be evaluated for each entry as a glob expression. As an example, **/.DS_Store is applied by default.

Arguments

Example

treediff.registerFilter('**/Folder-to-exclude/**');
treediff.registerFilter('**/*.docx');