npm

Need private packages and team management tools?Check out npm Orgs. »

copymitter

4.0.5 • Public • Published

Copymitter License NPM version Dependency Status Build Status Coverage Status

Copy files with emitter. It will emit event on every percent of copied chunk of data. Good for making progress bars.

Install

npm i copymitter

How to use?

const copymitter = require('copymitter');
const cwd = process.cwd();
const from = cwd + '/pipe-io';
const to = cwd + '/example';
const abortOnError = false;
 
const cp = copymitter(from, to, [
    'LICENSE',
    'README.md',
    'package.json'
]);
 
cp.on('file', function(from, to) {
    console.log(`${from} -> ${to}`);
});
 
cp.on('directory', function(from, to) {
    console.log(`${from} -> ${to}`);
});
 
cp.on('progress', function(percent) {
    console.log(percent);
    
    if (percent >= 50) {
        cp.pause();
        cp.continue();
    }
});
 
cp.on('pause', () => {
    console.log('paused');
    cp.continue();
});
 
cp.on('error', function(error, name, i, percent) {
    console.error(percent, ' -> ', name, ':', error.message);
    
    if (abortOnError)
        cp.abort();
    else
        cp.continue();
});
 
cp.on('end', function() {
    console.log('Copying ended up');
});
 
cp.pause();

Related

  • Remy - Remove files with emitter.
  • Jaguar - Pack and extract .tar.gz archives with emitter.
  • OneZip - Pack and extract zip archives with emitter.
  • Tar-to-zip - Convert tar and tar.gz archives to zip.

License

MIT

install

npm i copymitter

Downloadsweekly downloads

1,373

version

4.0.5

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability