3.0.0 • Published 4 years ago

syncy v3.0.0

Weekly downloads
237
License
MIT
Repository
github
Last release
4 years ago

SyncY

One-way synchronization of directories with glob.

Travis NPM version

Install

$ npm i -S syncy

Why?

  • Fast by using streams and Promises. Used cp-file and rimraf.
  • User-friendly by accepting globs.

Usage

const syncy = require('syncy');

syncy(['src/**', '!src/folder/**'], 'dest')
  .then(() => {
    console.log('Done!');
  })
  .catch(console.error);

API

syncy(patterns, dest, [options])

patterns

  • Type: string|string[]

Glob patterns that represent files to copy

dest

  • Type: string|string[]

Destination directory or directories.

options

  • Type: object
{
  // Display log messages when copying and removing files
  verbose: false,
  // Or create your own function.
  verbose: (stamp) {
    // action - `copy` or `remove`
    // to - only for `copy` action
    console.log(stamp.action + ' | ' + stamp.from + ' | ' + stamp.to);
  },
  // The base path to be removed from the path. Default: none
  base: 'base_path'
  // Remove all files from dest that are not found in src. Default: true
  updateAndDelete: true,
  // Never remove js files from destination. Default: false
  ignoreInDest: '**/*.js'
}

How to work with Gulp?

const gulp = require('gulp');
const syncy = require('syncy');

gulp.task('sync', (done) => {
  syncy(['node_modules/gulp/**'], 'dest')
    .then(() => {
      done();
    })
    .catch((err) => {
      done(err);
    });
});

How to work with Grunt?

const syncy = require('syncy');

module.exports = (grunt) => {
  // Default task(s).
  grunt.registerTask('default', function() {
    const done = this.async();
    syncy(['node_modules/grunt/**'], 'dest')
      .then(() => {
        done();
      })
      .catch((err) => {
        done(err);
      });
  });
};

Tests

Tech specs:

  • Intel Core i7-3610QM
  • RAM 8GB
  • SSD (555MB/S, 530MB/S)
  • Windows 10
  • Node.js v6.4.0

Files: AngularJS from release v1.6.0-rc.1.

Note: UpdateAndDelete option is enabled in the grunt-sync, because other plugins have this option initially.

Description of testssyncygulp-directory-syncgrunt-sync
First run3,7s9,1s10,1s
Re-run0,7s1,0s0,8s
Delete single file from dest directory0,7s0,9s0,8s

Changelog

See the Releases section of our GitHub project for changelogs for each release version.

License

This software is released under the terms of the MIT license.

3.0.0

4 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago