fast-extract
Version:
Extract contents from various archive types (tar, tar.bz2, tar.gz, tar.xz, tgz, zip)
24 lines (23 loc) • 755 B
JavaScript
import { Transform } from 'extract-base-iterator';
import { safeRm } from 'fs-remove-compat';
let DestinationRemove = class DestinationRemove extends Transform {
_transform(chunk, _encoding, callback) {
if (this.removed) return callback(null, chunk);
// safeRm handles non-existent paths gracefully (returns no error)
safeRm(this.dest, (err)=>{
this.removed = true;
err ? callback(err) : callback(null, chunk);
});
}
constructor(dest, options = {}){
options = options ? {
...options,
objectMode: true
} : {
objectMode: true
};
super(options);
this.dest = dest;
}
};
export { DestinationRemove as default };