Skip to content
move files
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
lib
test
.eslintrc
.eslintrc.test
.gitignore
.npmignore
.travis.yml
ChangeLog
LICENSE
README.md
package.json

README.md

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

You can’t perform that action at this time.