# fs-copy-file

> fs.copyFile ponyfill

Latest version **2.1.2** (published 2018-05-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install fs-copy-file
pnpm add fs-copy-file
yarn add fs-copy-file
bun add fs-copy-file
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.2 |
| Published | 2018-05-03 |
| First published | 2017-09-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 1 |
| Unpacked size | 8.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | coderaiser |
| Maintainers | coderaiser |
| Keywords | ponyfill, copy, file, copyFile, fs |

## Links

- npm: https://www.npmjs.com/package/fs-copy-file
- Repository: https://github.com/coderaiser/fs-copy-file
- Homepage: http://github.com/coderaiser/fs-copy-file
- Issues: https://github.com/coderaiser/fs-copy-file/issues
- npm.io page: https://npm.io/package/fs-copy-file

## Dependencies (1)

- [@cloudcmd/copy-file](https://npm.io/package/@cloudcmd/copy-file.md) ^1.1.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 2.1.2 (latest) — 2018-05-03
- 2.1.1 — 2018-05-03
- 2.1.0 — 2018-05-03
- 2.0.0 — 2018-05-02
- 1.0.2 — 2017-09-13
- 1.0.1 — 2017-09-13
- 1.0.0 — 2017-09-13

## README

fs-copy-file [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
=========
Node.js v8.5.0 [fs.copyFile](https://nodejs.org/dist/latest-v10.x/docs/api/fs.html#fs_fs_copyfile_src_dest_flags_callback) [ponyfill](https://ponyfill.com).

Asynchronously copies `src` to `dest`. By default, dest is overwritten if it already exists. No arguments other than a possible exception are given to the callback function. Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination.

`flags` is an optional integer that specifies the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. `fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).

- `fs.constants.COPYFILE_EXCL` - The copy operation will fail if dest already exists.
- `fs.constants.COPYFILE_FICLONE` - The copy operation will attempt to create a copy-on-write reflink. If the platform does not support copy-on-write, then a fallback copy mechanism is used.
- `fs.constants.COPYFILE_FICLONE_FORCE` - The copy operation will attempt to create a copy-on-write reflink. If the platform does not support copy-on-write, then the operation will fail.

## Install

```
npm i fs-copy-file
```

## API

Create pipe between streams and adds callback wich would 
be called once whenever everything is done, or error occures.

```js
const copyFile = require('fs-copy-file');

// destination.txt will be created or overwritten by default.
copyFile('source.txt', 'destination.txt', (err) => {
    if (err)
        throw err;
    
    console.log('source.txt was copied to destination.txt');
});
```

If the third argument is a number, then it specifies flags, as shown in the following example.

```js
const copyFile = require('fs-copy-file');
const { COPYFILE_EXCL } = copyFile.constants;

// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
fs.copyFile('source.txt', 'destination.txt', COPYFILE_EXCL, callback);
```

## Related

- [fs-copy-file-sync](https://github.com/coderaiser/fs-copy-file-sync "fs-copy-file-sync") - Synchronously copies src to dest.

## License
MIT

[NPMIMGURL]:                https://img.shields.io/npm/v/fs-copy-file.svg?style=flat
[BuildStatusIMGURL]:        https://img.shields.io/travis/coderaiser/fs-copy-file/master.svg?style=flat
[DependencyStatusIMGURL]:   https://img.shields.io/gemnasium/coderaiser/fs-copy-file.svg?style=flat
[LicenseIMGURL]:            https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[CoverageIMGURL]:           https://coveralls.io/repos/coderaiser/fs-copy-file/badge.svg?branch=master&service=github
[NPMURL]:                   https://npmjs.org/package/fs-copy-file "npm"
[BuildStatusURL]:           https://travis-ci.org/coderaiser/fs-copy-file  "Build Status"
[DependencyStatusURL]:      https://gemnasium.com/coderaiser/fs-copy-file "Dependency Status"
[LicenseURL]:               https://tldrlegal.com/license/mit-license "MIT License"
[CoverageURL]:              https://coveralls.io/github/coderaiser/fs-copy-file?branch=master

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