refactor(copy) rm error

This commit is contained in:
coderaiser 2017-02-07 11:04:00 +02:00
parent cb1fb02d86
commit 01fa5ffec8

View file

@ -292,22 +292,15 @@ function operation(op, from, to, names, fn) {
}
function copy(from, to, names, fn) {
let error;
const cp = copymitter(from, to, names);
cp.on('error', e => {
error = e;
cp.abort();
});
cp.on('progress', (count) => {
process.stdout.write(`\r copy ${from} ${to} ${count}%`);
});
cp.on('end', () => {
process.stdout.write('\n');
fn(error);
});
copymitter(from, to, names)
.on('error', fn)
.on('progress', (count) => {
process.stdout.write(`\r copy ${from} ${to} ${count}%`);
})
.on('end', () => {
process.stdout.write('\n');
fn();
});
}
function copyFiles(files, processFunc, callback) {