@fibjs/copy
Version:
copy file or directory recursively asynchronously.
66 lines (51 loc) • 2.07 kB
Markdown
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![appveyor build status][appveyor-image]][appveyor-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]
[]: https://img.shields.io/npm/v/@fibjs/copy.svg?style=flat-square
[]: https://npmjs.org/package/@fibjs/copy
[]: https://img.shields.io/travis/fibjs-modules/copy.svg?style=flat-square
[]: https://travis-ci.org/fibjs-modules/copy
[]: https://ci.appveyor.com/api/projects/status/hnsvto46bnirhx1v/branch/master?svg=true
[]: https://ci.appveyor.com/project/ngot/copy
[]: https://img.shields.io/codecov/c/github/fibjs-modules/copy.svg?style=flat-square
[]: https://codecov.io/github/fibjs-modules/copy?branch=master
[]: https://img.shields.io/david/fibjs-modules/copy.svg?style=flat-square
[]: https://david-dm.org/fibjs-modules/copy
[]: https://snyk.io/test/npm/@fibjs/copy/badge.svg?style=flat-square
[]: https://snyk.io/test/npm/@fibjs/copy
[]: https://img.shields.io/npm/dm/@fibjs/copy.svg?style=flat-square
[]: https://npmjs.org/package/@fibjs/copy
copy file or directory recursively asynchronously.
```bash
$ npm i @fibjs/copy --save
```
```js
const copy = require('@fibjs/copy');
copy('path to source', 'path to target');
copy('path to source', 'path to target', data => {
// process the file buffer before write to the target
return data.toString() + 'foo';
});
copy('path to source', 'path to target', (data, dir) => {
if (dir.src.endsWith('xxx')) {
// ignore this path
return false;
}
return data;
});
copy('path to source', 'path to target', () => {
// doing nothing
return true;
});
```
Please open an issue [here](https://github.com/fibjs-modules/copy/issues).
[](LICENSE)