tree-sync
A module for repeated efficient synchronizing two directories.
Last updated 2 months ago by stefanpenner .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install tree-sync 
SYNC missed versions from official npm registry.

TreeSync CI

A module for repeated efficient synchronizing two directories.

// input/a/{a.js,b.js}
// output/

const tree = new TreeSync('input', 'output');
tree.sync();
// output is now contains copies of everything that is in input

fs.unlink('/input/a/b.js');

// input / output have diverged

tree.sync();

// difference is calculated and efficient patch to update `output` is created and applied

Under the hood, this library uses walk-sync to traverse files and folders. You may optionally pass in options to selectively include or ignore files and directories. These whitelisted properties (ignore and globs) will be passed to walk-sync.

// Assume the following folder structure...
// input/
//   foo/
//     foo.js
//     bar.js
//   bar/
//     foo-bar.js

const tree = new TreeSync('input', 'output', {
  ignore: ['**/b']
});
tree.sync();

// We now expect output to contain foo/, but not bar/.
// Any changes made to bar/ won't be synced to output, and the contents of bar/ won't be traversed.
// Assume the following folder structure...
// input/
//   foo/
//     foo.js
//     bar.js
//   bar/
//     foo-bar.js

const tree = new TreeSync('input', 'output', {
  globs: ['foo', 'foo/bar.js']
});
tree.sync();

// We now expect output to contain foo/bar.js, but nothing else.
// Be careful when using this property! You'll need to make sure that if you're including a file, it's parent
// path is also included, or you'll get an error when tree-sync tries to copy the file over.

Current Tags

  • 2.1.0                                ...           latest (2 months ago)

16 Versions

  • 2.1.0                                ...           2 months ago
  • 2.0.0                                ...           2 years ago
  • 1.4.0                                ...           2 years ago
  • 1.3.0                                ...           2 years ago
  • 1.2.2                                ...           4 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.5                                ...           4 years ago
  • 1.1.4                                ...           4 years ago
  • 1.1.3                                ...           4 years ago
  • 1.1.2                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Downloads
Today 0
This Week 95
This Month 116
Last Day 7
Last Week 123
Last Month 465
Dependencies (5)
Dev Dependencies (4)

Copyright 2014 - 2016 © taobao.org |