fast-extract
Version:
Extract contents from various archive types (tar, tar.bz2, tar.gz, tar.xz, tgz, zip)
25 lines (24 loc) • 736 B
JavaScript
import { Transform } from 'stream';
import rimraf2 from 'rimraf2';
let DestinationRemove = class DestinationRemove extends Transform {
_transform(chunk, encoding, callback) {
if (this.removed) return callback(null, chunk, encoding);
rimraf2(this.dest, {
disableGlob: true
}, (err)=>{
this.removed = true;
err && err.code !== 'EEXIST' ? callback(err) : callback(null, chunk, encoding);
});
}
constructor(dest, options){
options = options ? {
...options,
objectMode: true
} : {
objectMode: true
};
super(options);
this.dest = dest;
}
};
export { DestinationRemove as default };