[nodejs] A promise to copy a file should be resolved when the target is closed not when the source is drained
@@ -89,10 +89,10 @@ exports.copy = function(src, dst) {
return new Promise(function(fulfill, reject) {
var rs = fs.createReadStream(src);
rs.on('error', reject);
- rs.on('end', () => fulfill(dst));
var ws = fs.createWriteStream(dst);
ws.on('error', reject);
+ ws.on('close', () => fulfill(dst));
rs.pipe(ws);
});
