Coder Social home page Coder Social logo

pk-nb / sync-directory Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hoperyy/sync-directory

0.0 1.0 0.0 22 KB

同步两个目录的文件(支持复制和生成硬连接的方式); sync two directories by copying or creating hardlink.

JavaScript 100.00%

sync-directory's Introduction

Description

sync-directory can sync files form src directory to target directory.

We have two ways to sync files: hardlink and copy.

If type is copy, sync-directory will copy files from src directory to target directory.

If type is hardlink, sync-directory can create hardlink files in target directory from src directory.

Apparently, the type hardlink is quicker than type copy, and sync-directory uses hardlink by default.

API

require('sync-directory')(srcDir, targetDir[, config]);
  • parames

    name description type values default
    srcDir src directory String absolute path -
    targetDir target directory String absolute path -
    config.watch watch files change Boolean - false
    config.type way to sync files String 'copy' / 'hardlink' 'hardlink'
    config.cb callback function when files synced Function - blank function
    config.exclude files that should not sync to target directory. RegExp / String / Array (item is RegExp / String) - null
  • return

    const watcher = require('sync-directory')(A, B);
    

    watcher is undefined.

    const watcher = require('sync-directory')(A, B, {
        watch: true
    });
    

    watcher is a chokidar watcher.

Examples

  • watch

    require('sync-directory')(srcDir, targetDir, {
        watch: true
    });
    
  • cb

    require('sync-directory')(srcDir, targetDir, {
        watch: true,
        cb({ type, path }) {
            // type: add / remove / unlink / unlinkDir
            // path: file path
        }
    });
    
  • type

    copy

    require('sync-directory')(srcDir, targetDir, {
        type: 'copy'
    });
    

    hardlink (default)

    require('sync-directory')(srcDir, targetDir);
    
  • exclude

    exclude node_modules

    • String

      require('sync-directory')(srcDir, targetDir, {
          exclude: 'node_modules'
      });
      
    • RegExp

      require('sync-directory')(srcDir, targetDir, {
          exclude: /node\_modules/
      });
      
    • Array

      require('sync-directory')(srcDir, targetDir, {
          exclude: [/node\_modules/]
      });
      
      require('sync-directory')(srcDir, targetDir, {
          exclude: ['node_modules']
      });
      

sync-directory's People

Contributors

hoperyy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.