# cpr

> cp -R

Latest version **3.0.1** (published 2017-10-31) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install cpr
pnpm add cpr
yarn add cpr
bun add cpr
```

Provides the command `cpr`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2017-10-31 |
| First published | 2012-10-04 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 82 |
| Author | Dav Glass |
| Maintainers | davglass |
| Keywords | copy, recursive, cp -r, cp |

## Links

- npm: https://www.npmjs.com/package/cpr
- Repository: https://github.com/davglass/cpr
- Homepage: https://github.com/davglass/cpr#readme
- Issues: http://github.com/davglass/cpr/issues
- npm.io page: https://npm.io/package/cpr

## Dependencies (4)

- [mkdirp](https://npm.io/package/mkdirp.md) ~0.5.1
- [rimraf](https://npm.io/package/rimraf.md) ^2.5.4
- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.1.5

## Recent versions

- 3.0.1 (latest) — 2017-10-31
- 3.0.0 — 2017-10-31
- 2.2.0 — 2017-06-26
- 2.1.0 — 2017-05-29
- 2.0.2 — 2016-12-21
- 2.0.1 — 2016-12-19
- 2.0.0 — 2016-08-15
- 1.1.2 — 2016-06-09
- 1.1.1 — 2016-04-06
- 1.1.0 — 2016-04-05
- 1.0.0 — 2015-11-13
- 0.4.3 — 2015-10-11
- 0.4.2 — 2015-09-12
- 0.4.1 — 2015-05-26
- 0.4.0 — 2015-02-15
- … 13 more at https://npm.io/package/cpr/versions

## README

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](https://secure.travis-ci.org/davglass/cpr.png)](http://travis-ci.org/davglass/cpr)

Usage
-----

```js
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](../master/cpr.jpg?raw=true)

---
_Source: https://npm.io/package/cpr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
