npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

copy-newer

v2.1.2

Published

Copy newer files only.

Downloads

246

Readme

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