feature(rest) copy: add progress

This commit is contained in:
coderaiser 2015-02-17 10:49:42 -05:00
parent 60971d7cce
commit 03d0c8c05c

View file

@ -287,6 +287,7 @@
function copy(from, to, names, fn) {
var error,
tmpl = '\r copy {{ from }} {{ to }} {{ count }}%',
cp = copymitter(from, to, names);
cp.on('error', function(e) {
@ -294,7 +295,16 @@
cp.abort();
});
cp.on('progress', function(count) {
process.stdout.write(rendy(tmpl, {
to: to,
from: from,
count: count
}));
});
cp.on('end', function() {
process.stdout.write('\n');
fn(error);
});
}