Removes tmp directory after copy, mimicing fs.rename

This commit is contained in:
Nathan Bleigh
2012-09-11 17:59:01 -05:00
parent dbcea61300
commit 62328d4bf5

View File

@@ -127,6 +127,7 @@ Package.prototype.install = function () {
if (err) return this.emit('error', err);
return fs.rename(this.path, this.localPath, function (err) {
if(err && err.code === 'EXDEV'){
console.log(this.path);
var reader = fstream.Reader(this.path).pipe(
fstream.Writer({
type: 'Directory',
@@ -134,7 +135,11 @@ Package.prototype.install = function () {
})
);
reader.on('error', this.emit.bind(this, 'error'));
reader.on('end', this.cleanUpLocal.bind(this));
reader.on('end', function(){
rimraf(this.path,function(err){
this.cleanUpLocal.bind(this);
}.bind(this));
}.bind(this));
return;
}
this.cleanUpLocal();