UNPKG

fast-extract

Version:

Extract contents from various archive types (tar, tar.bz2, tar.gz, tar.xz, tgz, zip)

28 lines (27 loc) 775 B
import rimraf2 from 'rimraf2'; import { Transform } from '../../compat/stream.js'; let DestinationRemove = class DestinationRemove extends Transform { _transform(chunk, _encoding, callback) { if (this.removed) { callback(null, chunk); return; } rimraf2(this.dest, { disableGlob: true }, (err)=>{ this.removed = true; err && err.code !== 'EEXIST' ? callback(err) : callback(null, chunk); }); } constructor(dest, options = {}){ options = options ? { ...options, objectMode: true } : { objectMode: true }; super(options); this.dest = dest; } }; export { DestinationRemove as default };