cpr
cp -R
Last updated 7 years ago by davglass .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ npm install cpr 
SYNC missed versions from official npm registry.

CPR (cp -R)

There are other modules out there that attempt this, but none did it the way I needed it to be done or they had issues and the author failed to fix them in a timely manner.

Install

npm install cpr

Build Status

Build Status

Usage

var cpr = require('cpr');
//or
var cpr = require('cpr').cpr; //Back compat

cpr('/path/from', '/path/to', {
    deleteFirst: true, //Delete "to" before
    overwrite: true, //If the file exists, overwrite it
    confirm: true //After the copy, stat all the copied files to make sure they are there
}, function(err, files) {
    //err - The error if any (err.list might be available with an array of errors for more detailed information)
    //files - List of files that we copied
});

cpr('/path/from', '/path/to', function(err, files) {
    //err - The error if any (err.list might be available with an array of errors for more detailed information)
    //      In the case of an error, cpr continues to copy files but returns this error object with all of the files that it failed to copy.
    //files - List of files that we copied
});

Options

All options default to false.

  • deleteFirst: Delete the to directory with rimraf
  • overwrite: If the destination exists, overwrite it
  • confirm: After the copy operation, stat all the files and report errors if any are missing
  • filter: RegExp or function to test each file against before copying

Filtering

If you give it a RegExp, it will use that to test the full absolute pathnames of the files and directories as they are being gathered. If any of them passes, it will not be copied. If you give it a function, it will use that with Array.filter on the list of full absolute pathnames of files and directories.

CLI

cpr can also be used from the command line which is useful for cross platform support.

Usage:

cpr <source> <destination> [options]

Copies files from source to destination.

Options:

  • -d, --delete-first: Delete the destination directory before copying.
  • -f <regex>, --filter <regex>: Filter out any items that match <regex>, a case-insensitive regex pattern.
  • -h, --help: Display this usage info.
  • -o, --overwrite: Overwrite the destination exists if it exists.
  • -v, --version: Display the cpr version.

Note that the CLI's filter option is simpler than the original NodeJS API, only accepting case-insensitive regular expression patterns and not functions.

cpr

Current Tags

  • 3.0.1                                ...           latest (7 years ago)

28 Versions

  • 3.0.1                                ...           7 years ago
  • 3.0.0                                ...           7 years ago
  • 2.2.0                                ...           7 years ago
  • 2.1.0                                ...           7 years ago
  • 2.0.2                                ...           8 years ago
  • 2.0.1                                ...           8 years ago
  • 2.0.0                                ...           8 years ago
  • 1.1.2                                ...           8 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
  • 0.4.3                                ...           9 years ago
  • 0.4.2                                ...           9 years ago
  • 0.4.1                                ...           9 years ago
  • 0.4.0                                ...           10 years ago
  • 0.3.3                                ...           10 years ago
  • 0.3.2                                ...           10 years ago
  • 0.3.1                                ...           10 years ago
  • 0.3.0                                ...           10 years ago
  • 0.2.0                                ...           11 years ago
  • 0.1.1                                ...           11 years ago
  • 0.1.0                                ...           12 years ago
  • 0.0.6                                ...           12 years ago
  • 0.0.5                                ...           12 years ago
  • 0.0.4                                ...           12 years ago
  • 0.0.3                                ...           12 years ago
  • 0.0.2                                ...           12 years ago
  • 0.0.1                                ...           12 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (5)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE