fast-extract
Version:
Extract contents from various archive types (tar, tar.bz2, tar.gz, tar.xz, tgz, zip)
27 lines (26 loc) • 837 B
JavaScript
import fs from 'fs';
import { Transform } from '../../compat/stream.js';
let DestinationNotExists = class DestinationNotExists extends Transform {
_transform(chunk, _encoding, callback) {
if (this.ready) {
callback(null, chunk);
return;
}
fs.readdir(this.dest, (dirErr, names)=>{
this.ready = true;
const err = !dirErr && names.length ? new Error(`Cannot overwrite ${this.dest} without force option`) : null;
err ? callback(err) : callback(null, chunk);
});
}
constructor(dest, options = {}){
options = options ? {
...options,
objectMode: true
} : {
objectMode: true
};
super(options);
this.dest = dest;
}
};
export { DestinationNotExists as default };