UNPKG

fast-extract

Version:

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

1 lines 1.7 kB
{"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":["DestinationNotExists","dest","options","objectMode","_transform","chunk","encoding","callback","ready","fs","readdir","dirErr","names","err","length","Error","Transform"],"mappings":";;;;;;;eAGqBA;;;yDAHN;sBACW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEX,IAAA,AAAMA,qCAAN;;cAAMA;aAAAA,qBACPC,IAAI,EAAEC,OAAO;gCADNF;;QAEjBE,UAAUA,UAAU,wCAAKA;YAASC,YAAY;aAAS;YAAEA,YAAY;QAAK;gBAC1E,kBAHiBH;YAGXE;;QACN,MAAKD,IAAI,GAAGA;;;iBAJKD;IAOnBI,OAAAA,UAOC,GAPDA,SAAAA,WAAWC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ;;QAClC,IAAI,IAAI,CAACC,KAAK,EAAE,OAAOD,SAAS,MAAMF,OAAOC;QAC7CG,WAAE,CAACC,OAAO,CAAC,IAAI,CAACT,IAAI,EAAE,SAACU,QAAQC;YAC7B,MAAKJ,KAAK,GAAG;YACb,IAAMK,MAAM,CAACF,UAAUC,MAAME,MAAM,GAAG,IAAIC,MAAM,AAAC,oBAA6B,OAAV,MAAKd,IAAI,EAAC,4BAA0B;YACxGY,MAAMN,SAASM,OAAON,SAAS,MAAMF,OAAOC;QAC9C;IACF;WAdmBN;EAA6BgB,iBAAS"}