@alexbinary/cp

1.0.1Β β€’Β PublicΒ β€’Β Published

cp

Simple file/directory copy with promise support πŸŽ‰

npm GitHub release Build Status dependencies Status devDependencies Status

Based on ncp by mmalecki

Uses @alexbinary/promisify and @alexbinary/callbackify by alexbinary

Install

Install with npm or yarn :

$ npm install @alexbinary/cp
# or
$ yarn add @alexbinary/cp

Usage

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

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

Package Sidebar

Install

npm i @alexbinary/cp

Weekly Downloads

3

Version

1.0.1

License

MIT

Last publish

Collaborators

  • alexbinary