Giter Site home page Giter Site logo

copy-newer's Introduction

copy-newer

Copy newer files only.

npm Build Status Coverage Status Dependency Status devDependency Status node

Usage

API

const copyNewer = require('copy-newer')

copyNewer(pattern, dest, [opts])

Copies files to a destination directory.

  • pattern: array|string - One or more glob patterns to select for the files to copy.
  • dest: string - The directory to copy to.
  • opts: object - Optional. Options to send directly to glob.
    • opts.interval: number - Optional. The number of milliseconds to wait before a file is considered 'new'. Default: 1000
    • opts.cwd: string - Same as glob's. The current working directory in which to search. Defaults to process.cwd(). (Included here because you'll most likely need it.)
    • opts.verbose: boolean - enable verbose logging to stdout. Defaults to false: no output ever occurs.
    • Other options can be found on glob's documentation.
  • Returns: Promise: Resolved when all file operations complete. Note: The resolved value is not empty, but it isn't useful either, for now. It's just an array of booleans that indicate whether each copy operation was done or skipped. For directories, a literal string dir will be represented in the output.

Note: fs.stat has a millisecond resolution while fs.utimes has a second resolution, hence the 1000 ms opts.interval. While node.js stays this way, changing opts.interval to a value lower than 1000 is not recommended.

CLI

copy-newer pattern dest [[--cwd] cwd]

Globs files with pattern mounted on cwd and copies them to dest.

Example

Copy the contents of "folder1" to "folder2":

copy-newer --cwd folder1 ** folder2

Options

  • pattern - (See API)
  • dest - (See API)
  • cwd - Sets opts.cwd. (See API)
  • -v, --verbose - Sets opts.verbose (See API)

All options are passed-through to glob via minimist, although only --cwd will be officially supported. (The issue here is glob isn't a CLI in the first place. Again, if anyone wants to discuss, hit up on Github.)

copy-newer-dir dirtocopy parentdest [pattern]

Takes a directory dirtocopy and copies it (and all of its contents) under parentdest.

Options

  • dirtocopy - The directory to copy.
  • parentdest - The directory to which to copy the directory and its contents.
  • pattern - Optional. The pattern to match files in the directory. Defaults to **.
  • -v, --verbose - sets opts.verbose

Again, all options are passed-through to glob, except --cwd won't have any effect.

Gotchas

Globbing directories won't copy their contents! You must glob their contents using **.

Similar packages

License

MIT

copy-newer's People

Contributors

seangenabe avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

copy-newer's Issues

"Middleware" support

Planning to add "middleware" support by exposing the output stream in a labeled-stream-splicer pipeline. This will make adding intermediate transform streams a breeze.

Yep, what Gulp does basically.

Included is support for the same in the CLI but with executing processes.

Does not work on Windows

This library does not seem to work on Windows.

Even trying something simple like this:

copyNewer = require('copy-newer');
copyNewer('c:/temp/x.c', 'C:\Temp\blah');

Gives the following error:

Error: ENOENT: no such file or directory, stat 'C:\Users\Haroldo\Projetos\32x\BlocklyVN32X\c:\temp\x.c'

stdin support

Planning to support a CLI -i / --stdin support. Basically the stdin is split and each line is processed just like a glob output. --cwd will be supported.

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.