npm

Bring the best of OSS JavaScript development to your projects with npm Orgs - private packages & team management tools.Learn more »

@cloudcmd/move-files

2.0.3 • Public • Published

Move Files License NPM version Dependency Status Build Status Coverage Status

Move files with emitter. Try to rename files first, and only if fail move them.

Install

npm i @cloudcmd/move-files

How to use?

const moveFiles = require('@cloudcmd/move-files');
const cwd = process.cwd();
const from = cwd + '/pipe-io';
const to = cwd + '/example';
const abortOnError = false;
 
const mv = moveFiles(from, to, [
    'LICENSE',
    'README.md',
    'package.json'
]);
 
mv.on('file', function(from, to) {
    console.log(`${from} -> ${to}`);
});
 
mv.on('directory', function(from, to) {
    console.log(`${from} -> ${to}`);
});
 
mv.on('progress', function(percent) {
    console.log(percent);
    
    if (percent >= 50) {
        mv.pause();
        mv.continue();
    }
});
 
mv.on('pause', () => {
    console.log('paused');
    mv.continue();
});
 
mv.on('error', (error) => {
    console.error(`${percent} -> ${name}${error.message}`);
    
    if (abortOnError)
        return mv.abort();
    
    mv.continue();
});
 
mv.on('end', function() {
    console.log('Moving ended up');
});
 
mv.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 @cloudcmd/move-files

Downloadsweekly downloads

365

version

2.0.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability