Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexbinary/cp
Simple file/directory copy with promise support 🎉
https://github.com/alexbinary/cp
Last synced: 1 day ago
JSON representation
Simple file/directory copy with promise support 🎉
- Host: GitHub
- URL: https://github.com/alexbinary/cp
- Owner: alexbinary
- License: mit
- Created: 2016-12-19T10:34:30.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-29T11:38:11.000Z (almost 8 years ago)
- Last Synced: 2024-10-22T22:36:53.931Z (25 days ago)
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# cp
Simple file/directory copy with promise support 🎉
[![npm](https://img.shields.io/npm/v/@alexbinary/cp.svg)](https://www.npmjs.com/package/@alexbinary/cp)
[![GitHub release](https://img.shields.io/github/release/alexbinary/cp.svg?label="github")](https://github.com/alexbinary/cp/releases/latest)
[![Build Status](https://travis-ci.org/alexbinary/cp.svg)](https://travis-ci.org/alexbinary/cp)
[![dependencies Status](https://david-dm.org/alexbinary/cp/status.svg)](https://david-dm.org/alexbinary/cp)
[![devDependencies Status](https://david-dm.org/alexbinary/cp/dev-status.svg)](https://david-dm.org/alexbinary/cp?type=dev)Based on [ncp](https://www.npmjs.com/package/ncp) by [mmalecki](https://www.npmjs.com/~mmalecki)
Uses [@alexbinary/promisify](https://www.npmjs.com/package/@alexbinary/promisify) and [@alexbinary/callbackify](https://www.npmjs.com/package/@alexbinary/callbackify) by [alexbinary](https://www.npmjs.com/~alexbinary)
## Install
Install with [npm](https://www.npmjs.com) or [yarn](https://yarnpkg.com) :
```bash
$ npm install @alexbinary/cp
# or
$ yarn add @alexbinary/cp
```## Usage
```javascript
let cp = require('@alexbinary/cp')// copy a file
cp('/source/foo.txt', '/target/foo.txt').then(() => {
// file /source/foo.txt is copied under /target/foo.txt
// folder /target is created if it does not exist
})// copy a folder
cp('/source/folder', '/target/folder').then(() => {
// folder /source/folder is copied with all its content under /target/folder
// folder /target is created if it does not exist
})
```## Documentation
```javascript
let cp = require('@alexbinary/cp')
```### cp(source, target)
Copies file or directory from `source` to `target`.
If `source` is a directory then it is copied with all its content.
Intermediate directories are created if necessary.
This method supports both Promise and node callback style, and resolves with no arguments.
### cp.sync(source, target)
Synchronous version.
## Licence
MIT