fast-extract
Version:
Extract contents from various archive types (tar, tar.bz2, tar.gz, tar.xz, tgz, zip)
1 lines • 1.63 kB
Source Map (JSON)
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/fast-extract/src/streams/transforms/DestinationNotExists.mjs"],"sourcesContent":["import fs from 'fs';\nimport { Transform } from 'stream';\n\nexport default class DestinationNotExists extends Transform {\n constructor(dest, options) {\n options = options ? { ...options, objectMode: true } : { objectMode: true };\n super(options);\n this.dest = dest;\n }\n\n _transform(chunk, encoding, callback) {\n if (this.ready) return callback(null, chunk, encoding);\n fs.readdir(this.dest, (dirErr, names) => {\n this.ready = true;\n const err = !dirErr && names.length ? new Error(`Cannot overwrite ${this.dest} without force option`) : null;\n err ? callback(err) : callback(null, chunk, encoding);\n });\n }\n}\n"],"names":["fs","Transform","DestinationNotExists","_transform","chunk","encoding","callback","ready","readdir","dest","dirErr","names","err","length","Error","constructor","options","objectMode"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,SAASC,SAAS,QAAQ,SAAS;AAEpB,IAAA,AAAMC,uBAAN,MAAMA,6BAA6BD;IAOhDE,WAAWC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAE;QACpC,IAAI,IAAI,CAACC,KAAK,EAAE,OAAOD,SAAS,MAAMF,OAAOC;QAC7CL,GAAGQ,OAAO,CAAC,IAAI,CAACC,IAAI,EAAE,CAACC,QAAQC;YAC7B,IAAI,CAACJ,KAAK,GAAG;YACb,MAAMK,MAAM,CAACF,UAAUC,MAAME,MAAM,GAAG,IAAIC,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAACL,IAAI,CAAC,qBAAqB,CAAC,IAAI;YACxGG,MAAMN,SAASM,OAAON,SAAS,MAAMF,OAAOC;QAC9C;IACF;IAbAU,YAAYN,IAAI,EAAEO,OAAO,CAAE;QACzBA,UAAUA,UAAU;YAAE,GAAGA,OAAO;YAAEC,YAAY;QAAK,IAAI;YAAEA,YAAY;QAAK;QAC1E,KAAK,CAACD;QACN,IAAI,CAACP,IAAI,GAAGA;IACd;AAUF;AAfA,SAAqBP,kCAepB"}