@jestaubach/fs-helpers 0.2.12 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1 @@
1
- (function(J,q){typeof exports=="object"&&typeof module<"u"?module.exports=q():typeof define=="function"&&define.amd?define(q):(J=typeof globalThis<"u"?globalThis:J||self,J["fs-helpers"]=q())})(this,function(){"use strict";var Xi=Object.defineProperty;var Hi=(J,q,X)=>q in J?Xi(J,q,{enumerable:!0,configurable:!0,writable:!0,value:X}):J[q]=X;var st=(J,q,X)=>(Hi(J,typeof q!="symbol"?q+"":q,X),X);var J=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function q(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function X(e){if(e.__esModule)return e;var n=e.default;if(typeof n=="function"){var t=function r(){if(this instanceof r){var i=[null];i.push.apply(i,arguments);var o=Function.bind.apply(n,i);return new o}return n.apply(this,arguments)};t.prototype=n.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}),t}var H={},W={};W.fromCallback=function(e){return Object.defineProperty(function(...n){if(typeof n[n.length-1]=="function")e.apply(this,n);else return new Promise((t,r)=>{e.call(this,...n,(i,o)=>i!=null?r(i):t(o))})},"name",{value:e.name})},W.fromPromise=function(e){return Object.defineProperty(function(...n){const t=n[n.length-1];if(typeof t!="function")return e.apply(this,n);e.apply(this,n.slice(0,-1)).then(r=>t(null,r),t)},"name",{value:e.name})};const N=X(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var V=N,at=process.cwd,ve=null,ft=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return ve||(ve=at.call(process)),ve};try{process.cwd()}catch{}if(typeof process.chdir=="function"){var Ve=process.chdir;process.chdir=function(e){ve=null,Ve.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Ve)}var lt=yt;function yt(e){V.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&n(e),e.lutimes||t(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=r(e.chmod),e.fchmod=r(e.fchmod),e.lchmod=r(e.lchmod),e.chownSync=c(e.chownSync),e.fchownSync=c(e.fchownSync),e.lchownSync=c(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(e.lchmodSync),e.stat=s(e.stat),e.fstat=s(e.fstat),e.lstat=s(e.lstat),e.statSync=f(e.statSync),e.fstatSync=f(e.fstatSync),e.lstatSync=f(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(u,y,d){d&&process.nextTick(d)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(u,y,d,m){m&&process.nextTick(m)},e.lchownSync=function(){}),ft==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:function(u){function y(d,m,h){var $=Date.now(),w=0;u(d,m,function k(p){if(p&&(p.code==="EACCES"||p.code==="EPERM")&&Date.now()-$<6e4){setTimeout(function(){e.stat(m,function(I,ne){I&&I.code==="ENOENT"?u(d,m,k):h(p)})},w),w<100&&(w+=10);return}h&&h(p)})}return Object.setPrototypeOf&&Object.setPrototypeOf(y,u),y}(e.rename)),e.read=typeof e.read!="function"?e.read:function(u){function y(d,m,h,$,w,k){var p;if(k&&typeof k=="function"){var I=0;p=function(ne,ue,Te){if(ne&&ne.code==="EAGAIN"&&I<10)return I++,u.call(e,d,m,h,$,w,p);k.apply(this,arguments)}}return u.call(e,d,m,h,$,w,p)}return Object.setPrototypeOf&&Object.setPrototypeOf(y,u),y}(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:function(u){return function(y,d,m,h,$){for(var w=0;;)try{return u.call(e,y,d,m,h,$)}catch(k){if(k.code==="EAGAIN"&&w<10){w++;continue}throw k}}}(e.readSync);function n(u){u.lchmod=function(y,d,m){u.open(y,V.O_WRONLY|V.O_SYMLINK,d,function(h,$){if(h){m&&m(h);return}u.fchmod($,d,function(w){u.close($,function(k){m&&m(w||k)})})})},u.lchmodSync=function(y,d){var m=u.openSync(y,V.O_WRONLY|V.O_SYMLINK,d),h=!0,$;try{$=u.fchmodSync(m,d),h=!1}finally{if(h)try{u.closeSync(m)}catch{}else u.closeSync(m)}return $}}function t(u){V.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(y,d,m,h){u.open(y,V.O_SYMLINK,function($,w){if($){h&&h($);return}u.futimes(w,d,m,function(k){u.close(w,function(p){h&&h(k||p)})})})},u.lutimesSync=function(y,d,m){var h=u.openSync(y,V.O_SYMLINK),$,w=!0;try{$=u.futimesSync(h,d,m),w=!1}finally{if(w)try{u.closeSync(h)}catch{}else u.closeSync(h)}return $}):u.futimes&&(u.lutimes=function(y,d,m,h){h&&process.nextTick(h)},u.lutimesSync=function(){})}function r(u){return u&&function(y,d,m){return u.call(e,y,d,function(h){v(h)&&(h=null),m&&m.apply(this,arguments)})}}function i(u){return u&&function(y,d){try{return u.call(e,y,d)}catch(m){if(!v(m))throw m}}}function o(u){return u&&function(y,d,m,h){return u.call(e,y,d,m,function($){v($)&&($=null),h&&h.apply(this,arguments)})}}function c(u){return u&&function(y,d,m){try{return u.call(e,y,d,m)}catch(h){if(!v(h))throw h}}}function s(u){return u&&function(y,d,m){typeof d=="function"&&(m=d,d=null);function h($,w){w&&(w.uid<0&&(w.uid+=4294967296),w.gid<0&&(w.gid+=4294967296)),m&&m.apply(this,arguments)}return d?u.call(e,y,d,h):u.call(e,y,h)}}function f(u){return u&&function(y,d){var m=d?u.call(e,y,d):u.call(e,y);return m&&(m.uid<0&&(m.uid+=4294967296),m.gid<0&&(m.gid+=4294967296)),m}}function v(u){if(!u||u.code==="ENOSYS")return!0;var y=!process.getuid||process.getuid()!==0;return!!(y&&(u.code==="EINVAL"||u.code==="EPERM"))}}var Ke=N.Stream,mt=dt;function dt(e){return{ReadStream:n,WriteStream:t};function n(r,i){if(!(this instanceof n))return new n(r,i);Ke.call(this);var o=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var c=Object.keys(i),s=0,f=c.length;s<f;s++){var v=c[s];this[v]=i[v]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(u,y){if(u){o.emit("error",u),o.readable=!1;return}o.fd=y,o.emit("open",y),o._read()})}function t(r,i){if(!(this instanceof t))return new t(r,i);Ke.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var o=Object.keys(i),c=0,s=o.length;c<s;c++){var f=o[c];this[f]=i[f]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}var ht=vt,St=Object.getPrototypeOf||function(e){return e.__proto__};function vt(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var n={__proto__:St(e)};else var n=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}),n}var D=N,wt=lt,pt=mt,Et=ht,we=N,j,pe;typeof Symbol=="function"&&typeof Symbol.for=="function"?(j=Symbol.for("graceful-fs.queue"),pe=Symbol.for("graceful-fs.previous")):(j="___graceful-fs.queue",pe="___graceful-fs.previous");function $t(){}function ze(e,n){Object.defineProperty(e,j,{get:function(){return n}})}var Z=$t;if(we.debuglog?Z=we.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Z=function(){var e=we.format.apply(we,arguments);e="GFS4: "+e.split(/\n/).join(`
2
- GFS4: `),console.error(e)}),!D[j]){var kt=J[j]||[];ze(D,kt),D.close=function(e){function n(t,r){return e.call(D,t,function(i){i||Qe(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(n,pe,{value:e}),n}(D.close),D.closeSync=function(e){function n(t){e.apply(D,arguments),Qe()}return Object.defineProperty(n,pe,{value:e}),n}(D.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Z(D[j]),N.equal(D[j].length,0)})}J[j]||ze(J,D[j]);var A=xe(Et(D));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!D.__patched&&(A=xe(D),D.__patched=!0);function xe(e){wt(e),e.gracefulify=xe,e.createReadStream=ue,e.createWriteStream=Te;var n=e.readFile;e.readFile=t;function t(S,a,l){return typeof a=="function"&&(l=a,a=null),O(S,a,l);function O(L,C,P,_){return n(L,C,function(g){g&&(g.code==="EMFILE"||g.code==="ENFILE")?te([O,[L,C,P],g,_||Date.now(),Date.now()]):typeof P=="function"&&P.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=i;function i(S,a,l,O){return typeof l=="function"&&(O=l,l=null),L(S,a,l,O);function L(C,P,_,g,M){return r(C,P,_,function(F){F&&(F.code==="EMFILE"||F.code==="ENFILE")?te([L,[C,P,_,g],F,M||Date.now(),Date.now()]):typeof g=="function"&&g.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=c);function c(S,a,l,O){return typeof l=="function"&&(O=l,l=null),L(S,a,l,O);function L(C,P,_,g,M){return o(C,P,_,function(F){F&&(F.code==="EMFILE"||F.code==="ENFILE")?te([L,[C,P,_,g],F,M||Date.now(),Date.now()]):typeof g=="function"&&g.apply(this,arguments)})}}var s=e.copyFile;s&&(e.copyFile=f);function f(S,a,l,O){return typeof l=="function"&&(O=l,l=0),L(S,a,l,O);function L(C,P,_,g,M){return s(C,P,_,function(F){F&&(F.code==="EMFILE"||F.code==="ENFILE")?te([L,[C,P,_,g],F,M||Date.now(),Date.now()]):typeof g=="function"&&g.apply(this,arguments)})}}var v=e.readdir;e.readdir=y;var u=/^v[0-5]\./;function y(S,a,l){typeof a=="function"&&(l=a,a=null);var O=u.test(process.version)?function(P,_,g,M){return v(P,L(P,_,g,M))}:function(P,_,g,M){return v(P,_,L(P,_,g,M))};return O(S,a,l);function L(C,P,_,g){return function(M,F){M&&(M.code==="EMFILE"||M.code==="ENFILE")?te([O,[C,P,_],M,g||Date.now(),Date.now()]):(F&&F.sort&&F.sort(),typeof _=="function"&&_.call(this,M,F))}}}if(process.version.substr(0,4)==="v0.8"){var d=pt(e);k=d.ReadStream,I=d.WriteStream}var m=e.ReadStream;m&&(k.prototype=Object.create(m.prototype),k.prototype.open=p);var h=e.WriteStream;h&&(I.prototype=Object.create(h.prototype),I.prototype.open=ne),Object.defineProperty(e,"ReadStream",{get:function(){return k},set:function(S){k=S},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return I},set:function(S){I=S},enumerable:!0,configurable:!0});var $=k;Object.defineProperty(e,"FileReadStream",{get:function(){return $},set:function(S){$=S},enumerable:!0,configurable:!0});var w=I;Object.defineProperty(e,"FileWriteStream",{get:function(){return w},set:function(S){w=S},enumerable:!0,configurable:!0});function k(S,a){return this instanceof k?(m.apply(this,arguments),this):k.apply(Object.create(k.prototype),arguments)}function p(){var S=this;Se(S.path,S.flags,S.mode,function(a,l){a?(S.autoClose&&S.destroy(),S.emit("error",a)):(S.fd=l,S.emit("open",l),S.read())})}function I(S,a){return this instanceof I?(h.apply(this,arguments),this):I.apply(Object.create(I.prototype),arguments)}function ne(){var S=this;Se(S.path,S.flags,S.mode,function(a,l){a?(S.destroy(),S.emit("error",a)):(S.fd=l,S.emit("open",l))})}function ue(S,a){return new e.ReadStream(S,a)}function Te(S,a){return new e.WriteStream(S,a)}var Ge=e.open;e.open=Se;function Se(S,a,l,O){return typeof l=="function"&&(O=l,l=null),L(S,a,l,O);function L(C,P,_,g,M){return Ge(C,P,_,function(F,ro){F&&(F.code==="EMFILE"||F.code==="ENFILE")?te([L,[C,P,_,g],F,M||Date.now(),Date.now()]):typeof g=="function"&&g.apply(this,arguments)})}}return e}function te(e){Z("ENQUEUE",e[0].name,e[1]),D[j].push(e),Ce()}var Ee;function Qe(){for(var e=Date.now(),n=0;n<D[j].length;++n)D[j][n].length>2&&(D[j][n][3]=e,D[j][n][4]=e);Ce()}function Ce(){if(clearTimeout(Ee),Ee=void 0,D[j].length!==0){var e=D[j].shift(),n=e[0],t=e[1],r=e[2],i=e[3],o=e[4];if(i===void 0)Z("RETRY",n.name,t),n.apply(null,t);else if(Date.now()-i>=6e4){Z("TIMEOUT",n.name,t);var c=t.pop();typeof c=="function"&&c.call(null,r)}else{var s=Date.now()-o,f=Math.max(o-i,1),v=Math.min(f*1.2,100);s>=v?(Z("RETRY",n.name,t),n.apply(null,t.concat([i]))):D[j].push(e)}Ee===void 0&&(Ee=setTimeout(Ce,0))}}(function(e){const n=W.fromCallback,t=A,r=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchmod","lchown","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter(i=>typeof t[i]=="function");Object.assign(e,t),r.forEach(i=>{e[i]=n(t[i])}),e.exists=function(i,o){return typeof o=="function"?t.exists(i,o):new Promise(c=>t.exists(i,c))},e.read=function(i,o,c,s,f,v){return typeof v=="function"?t.read(i,o,c,s,f,v):new Promise((u,y)=>{t.read(i,o,c,s,f,(d,m,h)=>{if(d)return y(d);u({bytesRead:m,buffer:h})})})},e.write=function(i,o,...c){return typeof c[c.length-1]=="function"?t.write(i,o,...c):new Promise((s,f)=>{t.write(i,o,...c,(v,u,y)=>{if(v)return f(v);s({bytesWritten:u,buffer:y})})})},typeof t.writev=="function"&&(e.writev=function(i,o,...c){return typeof c[c.length-1]=="function"?t.writev(i,o,...c):new Promise((s,f)=>{t.writev(i,o,...c,(v,u,y)=>{if(v)return f(v);s({bytesWritten:u,buffers:y})})})}),typeof t.realpath.native=="function"?e.realpath.native=n(t.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")})(H);var je={},Xe={};const gt=N;Xe.checkPath=function(n){if(process.platform==="win32"&&/[<>:"|?*]/.test(n.replace(gt.parse(n).root,""))){const r=new Error(`Path contains invalid characters: ${n}`);throw r.code="EINVAL",r}};const He=H,{checkPath:Ze}=Xe,en=e=>{const n={mode:511};return typeof e=="number"?e:{...n,...e}.mode};je.makeDir=async(e,n)=>(Ze(e),He.mkdir(e,{mode:en(n),recursive:!0})),je.makeDirSync=(e,n)=>(Ze(e),He.mkdirSync(e,{mode:en(n),recursive:!0}));const Ft=W.fromPromise,{makeDir:Dt,makeDirSync:Ie}=je,Le=Ft(Dt);var G={mkdirs:Le,mkdirsSync:Ie,mkdirp:Le,mkdirpSync:Ie,ensureDir:Le,ensureDirSync:Ie};const Ot=W.fromPromise,nn=H;function Pt(e){return nn.access(e).then(()=>!0).catch(()=>!1)}var ee={pathExists:Ot(Pt),pathExistsSync:nn.existsSync};const re=A;function _t(e,n,t,r){re.open(e,"r+",(i,o)=>{if(i)return r(i);re.futimes(o,n,t,c=>{re.close(o,s=>{r&&r(c||s)})})})}function Nt(e,n,t){const r=re.openSync(e,"r+");return re.futimesSync(r,n,t),re.closeSync(r)}var tn={utimesMillis:_t,utimesMillisSync:Nt};const ie=H,x=N,Tt=N;function xt(e,n,t){const r=t.dereference?i=>ie.stat(i,{bigint:!0}):i=>ie.lstat(i,{bigint:!0});return Promise.all([r(e),r(n).catch(i=>{if(i.code==="ENOENT")return null;throw i})]).then(([i,o])=>({srcStat:i,destStat:o}))}function Ct(e,n,t){let r;const i=t.dereference?c=>ie.statSync(c,{bigint:!0}):c=>ie.lstatSync(c,{bigint:!0}),o=i(e);try{r=i(n)}catch(c){if(c.code==="ENOENT")return{srcStat:o,destStat:null};throw c}return{srcStat:o,destStat:r}}function jt(e,n,t,r,i){Tt.callbackify(xt)(e,n,r,(o,c)=>{if(o)return i(o);const{srcStat:s,destStat:f}=c;if(f){if(se(s,f)){const v=x.basename(e),u=x.basename(n);return t==="move"&&v!==u&&v.toLowerCase()===u.toLowerCase()?i(null,{srcStat:s,destStat:f,isChangingCase:!0}):i(new Error("Source and destination must not be the same."))}if(s.isDirectory()&&!f.isDirectory())return i(new Error(`Cannot overwrite non-directory '${n}' with directory '${e}'.`));if(!s.isDirectory()&&f.isDirectory())return i(new Error(`Cannot overwrite directory '${n}' with non-directory '${e}'.`))}return s.isDirectory()&&Me(e,n)?i(new Error($e(e,n,t))):i(null,{srcStat:s,destStat:f})})}function It(e,n,t,r){const{srcStat:i,destStat:o}=Ct(e,n,r);if(o){if(se(i,o)){const c=x.basename(e),s=x.basename(n);if(t==="move"&&c!==s&&c.toLowerCase()===s.toLowerCase())return{srcStat:i,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${n}' with directory '${e}'.`);if(!i.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${n}' with non-directory '${e}'.`)}if(i.isDirectory()&&Me(e,n))throw new Error($e(e,n,t));return{srcStat:i,destStat:o}}function rn(e,n,t,r,i){const o=x.resolve(x.dirname(e)),c=x.resolve(x.dirname(t));if(c===o||c===x.parse(c).root)return i();ie.stat(c,{bigint:!0},(s,f)=>s?s.code==="ENOENT"?i():i(s):se(n,f)?i(new Error($e(e,t,r))):rn(e,n,c,r,i))}function on(e,n,t,r){const i=x.resolve(x.dirname(e)),o=x.resolve(x.dirname(t));if(o===i||o===x.parse(o).root)return;let c;try{c=ie.statSync(o,{bigint:!0})}catch(s){if(s.code==="ENOENT")return;throw s}if(se(n,c))throw new Error($e(e,t,r));return on(e,n,o,r)}function se(e,n){return n.ino&&n.dev&&n.ino===e.ino&&n.dev===e.dev}function Me(e,n){const t=x.resolve(e).split(x.sep).filter(i=>i),r=x.resolve(n).split(x.sep).filter(i=>i);return t.reduce((i,o,c)=>i&&r[c]===o,!0)}function $e(e,n,t){return`Cannot ${t} '${e}' to a subdirectory of itself, '${n}'.`}var oe={checkPaths:jt,checkPathsSync:It,checkParentPaths:rn,checkParentPathsSync:on,isSrcSubdir:Me,areIdentical:se};const B=A,ae=N,Lt=G.mkdirs,Mt=ee.pathExists,Rt=tn.utimesMillis,fe=oe;function Wt(e,n,t,r){typeof t=="function"&&!r?(r=t,t={}):typeof t=="function"&&(t={filter:t}),r=r||function(){},t=t||{},t.clobber="clobber"in t?!!t.clobber:!0,t.overwrite="overwrite"in t?!!t.overwrite:t.clobber,t.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
3
-
4
- see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0001"),fe.checkPaths(e,n,"copy",t,(i,o)=>{if(i)return r(i);const{srcStat:c,destStat:s}=o;fe.checkParentPaths(e,c,n,"copy",f=>f?r(f):t.filter?un(cn,s,e,n,t,r):cn(s,e,n,t,r))})}function cn(e,n,t,r,i){const o=ae.dirname(t);Mt(o,(c,s)=>{if(c)return i(c);if(s)return ke(e,n,t,r,i);Lt(o,f=>f?i(f):ke(e,n,t,r,i))})}function un(e,n,t,r,i,o){Promise.resolve(i.filter(t,r)).then(c=>c?e(n,t,r,i,o):o(),c=>o(c))}function At(e,n,t,r,i){return r.filter?un(ke,e,n,t,r,i):ke(e,n,t,r,i)}function ke(e,n,t,r,i){(r.dereference?B.stat:B.lstat)(n,(c,s)=>c?i(c):s.isDirectory()?Gt(s,e,n,t,r,i):s.isFile()||s.isCharacterDevice()||s.isBlockDevice()?bt(s,e,n,t,r,i):s.isSymbolicLink()?zt(e,n,t,r,i):s.isSocket()?i(new Error(`Cannot copy a socket file: ${n}`)):s.isFIFO()?i(new Error(`Cannot copy a FIFO pipe: ${n}`)):i(new Error(`Unknown file: ${n}`)))}function bt(e,n,t,r,i,o){return n?Bt(e,t,r,i,o):sn(e,t,r,i,o)}function Bt(e,n,t,r,i){if(r.overwrite)B.unlink(t,o=>o?i(o):sn(e,n,t,r,i));else return r.errorOnExist?i(new Error(`'${t}' already exists`)):i()}function sn(e,n,t,r,i){B.copyFile(n,t,o=>o?i(o):r.preserveTimestamps?Jt(e.mode,n,t,i):ge(t,e.mode,i))}function Jt(e,n,t,r){return qt(e)?Yt(t,e,i=>i?r(i):an(e,n,t,r)):an(e,n,t,r)}function qt(e){return(e&128)===0}function Yt(e,n,t){return ge(e,n|128,t)}function an(e,n,t,r){Ut(n,t,i=>i?r(i):ge(t,e,r))}function ge(e,n,t){return B.chmod(e,n,t)}function Ut(e,n,t){B.stat(e,(r,i)=>r?t(r):Rt(n,i.atime,i.mtime,t))}function Gt(e,n,t,r,i,o){return n?fn(t,r,i,o):Vt(e.mode,t,r,i,o)}function Vt(e,n,t,r,i){B.mkdir(t,o=>{if(o)return i(o);fn(n,t,r,c=>c?i(c):ge(t,e,i))})}function fn(e,n,t,r){B.readdir(e,(i,o)=>i?r(i):ln(o,e,n,t,r))}function ln(e,n,t,r,i){const o=e.pop();return o?Kt(e,o,n,t,r,i):i()}function Kt(e,n,t,r,i,o){const c=ae.join(t,n),s=ae.join(r,n);fe.checkPaths(c,s,"copy",i,(f,v)=>{if(f)return o(f);const{destStat:u}=v;At(u,c,s,i,y=>y?o(y):ln(e,t,r,i,o))})}function zt(e,n,t,r,i){B.readlink(n,(o,c)=>{if(o)return i(o);if(r.dereference&&(c=ae.resolve(process.cwd(),c)),e)B.readlink(t,(s,f)=>s?s.code==="EINVAL"||s.code==="UNKNOWN"?B.symlink(c,t,i):i(s):(r.dereference&&(f=ae.resolve(process.cwd(),f)),fe.isSrcSubdir(c,f)?i(new Error(`Cannot copy '${c}' to a subdirectory of itself, '${f}'.`)):e.isDirectory()&&fe.isSrcSubdir(f,c)?i(new Error(`Cannot overwrite '${f}' with '${c}'.`)):Qt(c,t,i)));else return B.symlink(c,t,i)})}function Qt(e,n,t){B.unlink(n,r=>r?t(r):B.symlink(e,n,t))}var Xt=Wt;const R=A,le=N,Ht=G.mkdirsSync,Zt=tn.utimesMillisSync,ye=oe;function er(e,n,t){typeof t=="function"&&(t={filter:t}),t=t||{},t.clobber="clobber"in t?!!t.clobber:!0,t.overwrite="overwrite"in t?!!t.overwrite:t.clobber,t.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
5
-
6
- see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0002");const{srcStat:r,destStat:i}=ye.checkPathsSync(e,n,"copy",t);return ye.checkParentPathsSync(e,r,n,"copy"),nr(i,e,n,t)}function nr(e,n,t,r){if(r.filter&&!r.filter(n,t))return;const i=le.dirname(t);return R.existsSync(i)||Ht(i),yn(e,n,t,r)}function tr(e,n,t,r){if(!(r.filter&&!r.filter(n,t)))return yn(e,n,t,r)}function yn(e,n,t,r){const o=(r.dereference?R.statSync:R.lstatSync)(n);if(o.isDirectory())return ar(o,e,n,t,r);if(o.isFile()||o.isCharacterDevice()||o.isBlockDevice())return rr(o,e,n,t,r);if(o.isSymbolicLink())return yr(e,n,t,r);throw o.isSocket()?new Error(`Cannot copy a socket file: ${n}`):o.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${n}`):new Error(`Unknown file: ${n}`)}function rr(e,n,t,r,i){return n?ir(e,t,r,i):mn(e,t,r,i)}function ir(e,n,t,r){if(r.overwrite)return R.unlinkSync(t),mn(e,n,t,r);if(r.errorOnExist)throw new Error(`'${t}' already exists`)}function mn(e,n,t,r){return R.copyFileSync(n,t),r.preserveTimestamps&&or(e.mode,n,t),Re(t,e.mode)}function or(e,n,t){return cr(e)&&ur(t,e),sr(n,t)}function cr(e){return(e&128)===0}function ur(e,n){return Re(e,n|128)}function Re(e,n){return R.chmodSync(e,n)}function sr(e,n){const t=R.statSync(e);return Zt(n,t.atime,t.mtime)}function ar(e,n,t,r,i){return n?dn(t,r,i):fr(e.mode,t,r,i)}function fr(e,n,t,r){return R.mkdirSync(t),dn(n,t,r),Re(t,e)}function dn(e,n,t){R.readdirSync(e).forEach(r=>lr(r,e,n,t))}function lr(e,n,t,r){const i=le.join(n,e),o=le.join(t,e),{destStat:c}=ye.checkPathsSync(i,o,"copy",r);return tr(c,i,o,r)}function yr(e,n,t,r){let i=R.readlinkSync(n);if(r.dereference&&(i=le.resolve(process.cwd(),i)),e){let o;try{o=R.readlinkSync(t)}catch(c){if(c.code==="EINVAL"||c.code==="UNKNOWN")return R.symlinkSync(i,t);throw c}if(r.dereference&&(o=le.resolve(process.cwd(),o)),ye.isSrcSubdir(i,o))throw new Error(`Cannot copy '${i}' to a subdirectory of itself, '${o}'.`);if(R.statSync(t).isDirectory()&&ye.isSrcSubdir(o,i))throw new Error(`Cannot overwrite '${o}' with '${i}'.`);return mr(i,t)}else return R.symlinkSync(i,t)}function mr(e,n){return R.unlinkSync(n),R.symlinkSync(e,n)}var dr=er;const hr=W.fromCallback;var We={copy:hr(Xt),copySync:dr};const hn=A,Sn=N,E=N,me=process.platform==="win32";function vn(e){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach(t=>{e[t]=e[t]||hn[t],t=t+"Sync",e[t]=e[t]||hn[t]}),e.maxBusyTries=e.maxBusyTries||3}function Ae(e,n,t){let r=0;typeof n=="function"&&(t=n,n={}),E(e,"rimraf: missing path"),E.strictEqual(typeof e,"string","rimraf: path should be a string"),E.strictEqual(typeof t,"function","rimraf: callback function required"),E(n,"rimraf: invalid options argument provided"),E.strictEqual(typeof n,"object","rimraf: options should be object"),vn(n),wn(e,n,function i(o){if(o){if((o.code==="EBUSY"||o.code==="ENOTEMPTY"||o.code==="EPERM")&&r<n.maxBusyTries){r++;const c=r*100;return setTimeout(()=>wn(e,n,i),c)}o.code==="ENOENT"&&(o=null)}t(o)})}function wn(e,n,t){E(e),E(n),E(typeof t=="function"),n.lstat(e,(r,i)=>{if(r&&r.code==="ENOENT")return t(null);if(r&&r.code==="EPERM"&&me)return pn(e,n,r,t);if(i&&i.isDirectory())return Fe(e,n,r,t);n.unlink(e,o=>{if(o){if(o.code==="ENOENT")return t(null);if(o.code==="EPERM")return me?pn(e,n,o,t):Fe(e,n,o,t);if(o.code==="EISDIR")return Fe(e,n,o,t)}return t(o)})})}function pn(e,n,t,r){E(e),E(n),E(typeof r=="function"),n.chmod(e,438,i=>{i?r(i.code==="ENOENT"?null:t):n.stat(e,(o,c)=>{o?r(o.code==="ENOENT"?null:t):c.isDirectory()?Fe(e,n,t,r):n.unlink(e,r)})})}function En(e,n,t){let r;E(e),E(n);try{n.chmodSync(e,438)}catch(i){if(i.code==="ENOENT")return;throw t}try{r=n.statSync(e)}catch(i){if(i.code==="ENOENT")return;throw t}r.isDirectory()?De(e,n,t):n.unlinkSync(e)}function Fe(e,n,t,r){E(e),E(n),E(typeof r=="function"),n.rmdir(e,i=>{i&&(i.code==="ENOTEMPTY"||i.code==="EEXIST"||i.code==="EPERM")?Sr(e,n,r):i&&i.code==="ENOTDIR"?r(t):r(i)})}function Sr(e,n,t){E(e),E(n),E(typeof t=="function"),n.readdir(e,(r,i)=>{if(r)return t(r);let o=i.length,c;if(o===0)return n.rmdir(e,t);i.forEach(s=>{Ae(Sn.join(e,s),n,f=>{if(!c){if(f)return t(c=f);--o===0&&n.rmdir(e,t)}})})})}function $n(e,n){let t;n=n||{},vn(n),E(e,"rimraf: missing path"),E.strictEqual(typeof e,"string","rimraf: path should be a string"),E(n,"rimraf: missing options"),E.strictEqual(typeof n,"object","rimraf: options should be object");try{t=n.lstatSync(e)}catch(r){if(r.code==="ENOENT")return;r.code==="EPERM"&&me&&En(e,n,r)}try{t&&t.isDirectory()?De(e,n,null):n.unlinkSync(e)}catch(r){if(r.code==="ENOENT")return;if(r.code==="EPERM")return me?En(e,n,r):De(e,n,r);if(r.code!=="EISDIR")throw r;De(e,n,r)}}function De(e,n,t){E(e),E(n);try{n.rmdirSync(e)}catch(r){if(r.code==="ENOTDIR")throw t;if(r.code==="ENOTEMPTY"||r.code==="EEXIST"||r.code==="EPERM")vr(e,n);else if(r.code!=="ENOENT")throw r}}function vr(e,n){if(E(e),E(n),n.readdirSync(e).forEach(t=>$n(Sn.join(e,t),n)),me){const t=Date.now();do try{return n.rmdirSync(e,n)}catch{}while(Date.now()-t<500)}else return n.rmdirSync(e,n)}var wr=Ae;Ae.sync=$n;const Oe=A,pr=W.fromCallback,kn=wr;function Er(e,n){if(Oe.rm)return Oe.rm(e,{recursive:!0,force:!0},n);kn(e,n)}function $r(e){if(Oe.rmSync)return Oe.rmSync(e,{recursive:!0,force:!0});kn.sync(e)}var Pe={remove:pr(Er),removeSync:$r};const kr=W.fromPromise,gn=H,Fn=N,Dn=G,On=Pe,Pn=kr(async function(n){let t;try{t=await gn.readdir(n)}catch{return Dn.mkdirs(n)}return Promise.all(t.map(r=>On.remove(Fn.join(n,r))))});function _n(e){let n;try{n=gn.readdirSync(e)}catch{return Dn.mkdirsSync(e)}n.forEach(t=>{t=Fn.join(e,t),On.removeSync(t)})}var gr={emptyDirSync:_n,emptydirSync:_n,emptyDir:Pn,emptydir:Pn};const Fr=W.fromCallback,Nn=N,K=A,Tn=G;function Dr(e,n){function t(){K.writeFile(e,"",r=>{if(r)return n(r);n()})}K.stat(e,(r,i)=>{if(!r&&i.isFile())return n();const o=Nn.dirname(e);K.stat(o,(c,s)=>{if(c)return c.code==="ENOENT"?Tn.mkdirs(o,f=>{if(f)return n(f);t()}):n(c);s.isDirectory()?t():K.readdir(o,f=>{if(f)return n(f)})})})}function Or(e){let n;try{n=K.statSync(e)}catch{}if(n&&n.isFile())return;const t=Nn.dirname(e);try{K.statSync(t).isDirectory()||K.readdirSync(t)}catch(r){if(r&&r.code==="ENOENT")Tn.mkdirsSync(t);else throw r}K.writeFileSync(e,"")}var Pr={createFile:Fr(Dr),createFileSync:Or};const _r=W.fromCallback,xn=N,z=A,Cn=G,Nr=ee.pathExists,{areIdentical:jn}=oe;function Tr(e,n,t){function r(i,o){z.link(i,o,c=>{if(c)return t(c);t(null)})}z.lstat(n,(i,o)=>{z.lstat(e,(c,s)=>{if(c)return c.message=c.message.replace("lstat","ensureLink"),t(c);if(o&&jn(s,o))return t(null);const f=xn.dirname(n);Nr(f,(v,u)=>{if(v)return t(v);if(u)return r(e,n);Cn.mkdirs(f,y=>{if(y)return t(y);r(e,n)})})})})}function xr(e,n){let t;try{t=z.lstatSync(n)}catch{}try{const o=z.lstatSync(e);if(t&&jn(o,t))return}catch(o){throw o.message=o.message.replace("lstat","ensureLink"),o}const r=xn.dirname(n);return z.existsSync(r)||Cn.mkdirsSync(r),z.linkSync(e,n)}var Cr={createLink:_r(Tr),createLinkSync:xr};const Q=N,de=A,jr=ee.pathExists;function Ir(e,n,t){if(Q.isAbsolute(e))return de.lstat(e,r=>r?(r.message=r.message.replace("lstat","ensureSymlink"),t(r)):t(null,{toCwd:e,toDst:e}));{const r=Q.dirname(n),i=Q.join(r,e);return jr(i,(o,c)=>o?t(o):c?t(null,{toCwd:i,toDst:e}):de.lstat(e,s=>s?(s.message=s.message.replace("lstat","ensureSymlink"),t(s)):t(null,{toCwd:e,toDst:Q.relative(r,e)})))}}function Lr(e,n){let t;if(Q.isAbsolute(e)){if(t=de.existsSync(e),!t)throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}else{const r=Q.dirname(n),i=Q.join(r,e);if(t=de.existsSync(i),t)return{toCwd:i,toDst:e};if(t=de.existsSync(e),!t)throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:Q.relative(r,e)}}}var Mr={symlinkPaths:Ir,symlinkPathsSync:Lr};const In=A;function Rr(e,n,t){if(t=typeof n=="function"?n:t,n=typeof n=="function"?!1:n,n)return t(null,n);In.lstat(e,(r,i)=>{if(r)return t(null,"file");n=i&&i.isDirectory()?"dir":"file",t(null,n)})}function Wr(e,n){let t;if(n)return n;try{t=In.lstatSync(e)}catch{return"file"}return t&&t.isDirectory()?"dir":"file"}var Ar={symlinkType:Rr,symlinkTypeSync:Wr};const br=W.fromCallback,Ln=N,Y=H,Mn=G,Br=Mn.mkdirs,Jr=Mn.mkdirsSync,Rn=Mr,qr=Rn.symlinkPaths,Yr=Rn.symlinkPathsSync,Wn=Ar,Ur=Wn.symlinkType,Gr=Wn.symlinkTypeSync,Vr=ee.pathExists,{areIdentical:An}=oe;function Kr(e,n,t,r){r=typeof t=="function"?t:r,t=typeof t=="function"?!1:t,Y.lstat(n,(i,o)=>{!i&&o.isSymbolicLink()?Promise.all([Y.stat(e),Y.stat(n)]).then(([c,s])=>{if(An(c,s))return r(null);bn(e,n,t,r)}):bn(e,n,t,r)})}function bn(e,n,t,r){qr(e,n,(i,o)=>{if(i)return r(i);e=o.toDst,Ur(o.toCwd,t,(c,s)=>{if(c)return r(c);const f=Ln.dirname(n);Vr(f,(v,u)=>{if(v)return r(v);if(u)return Y.symlink(e,n,s,r);Br(f,y=>{if(y)return r(y);Y.symlink(e,n,s,r)})})})})}function zr(e,n,t){let r;try{r=Y.lstatSync(n)}catch{}if(r&&r.isSymbolicLink()){const s=Y.statSync(e),f=Y.statSync(n);if(An(s,f))return}const i=Yr(e,n);e=i.toDst,t=Gr(i.toCwd,t);const o=Ln.dirname(n);return Y.existsSync(o)||Jr(o),Y.symlinkSync(e,n,t)}var Qr={createSymlink:br(Kr),createSymlinkSync:zr};const{createFile:Bn,createFileSync:Jn}=Pr,{createLink:qn,createLinkSync:Yn}=Cr,{createSymlink:Un,createSymlinkSync:Gn}=Qr;var Xr={createFile:Bn,createFileSync:Jn,ensureFile:Bn,ensureFileSync:Jn,createLink:qn,createLinkSync:Yn,ensureLink:qn,ensureLinkSync:Yn,createSymlink:Un,createSymlinkSync:Gn,ensureSymlink:Un,ensureSymlinkSync:Gn};function Hr(e,{EOL:n=`
7
- `,finalEOL:t=!0,replacer:r=null,spaces:i}={}){const o=t?n:"";return JSON.stringify(e,r,i).replace(/\n/g,n)+o}function Zr(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e.replace(/^\uFEFF/,"")}var be={stringify:Hr,stripBom:Zr};let ce;try{ce=A}catch{ce=N}const _e=W,{stringify:Vn,stripBom:Kn}=be;async function ei(e,n={}){typeof n=="string"&&(n={encoding:n});const t=n.fs||ce,r="throws"in n?n.throws:!0;let i=await _e.fromCallback(t.readFile)(e,n);i=Kn(i);let o;try{o=JSON.parse(i,n?n.reviver:null)}catch(c){if(r)throw c.message=`${e}: ${c.message}`,c;return null}return o}const ni=_e.fromPromise(ei);function ti(e,n={}){typeof n=="string"&&(n={encoding:n});const t=n.fs||ce,r="throws"in n?n.throws:!0;try{let i=t.readFileSync(e,n);return i=Kn(i),JSON.parse(i,n.reviver)}catch(i){if(r)throw i.message=`${e}: ${i.message}`,i;return null}}async function ri(e,n,t={}){const r=t.fs||ce,i=Vn(n,t);await _e.fromCallback(r.writeFile)(e,i,t)}const ii=_e.fromPromise(ri);function oi(e,n,t={}){const r=t.fs||ce,i=Vn(n,t);return r.writeFileSync(e,i,t)}var ci={readFile:ni,readFileSync:ti,writeFile:ii,writeFileSync:oi};const Ne=ci;var ui={readJson:Ne.readFile,readJsonSync:Ne.readFileSync,writeJson:Ne.writeFile,writeJsonSync:Ne.writeFileSync};const si=W.fromCallback,he=A,zn=N,Qn=G,ai=ee.pathExists;function fi(e,n,t,r){typeof t=="function"&&(r=t,t="utf8");const i=zn.dirname(e);ai(i,(o,c)=>{if(o)return r(o);if(c)return he.writeFile(e,n,t,r);Qn.mkdirs(i,s=>{if(s)return r(s);he.writeFile(e,n,t,r)})})}function li(e,...n){const t=zn.dirname(e);if(he.existsSync(t))return he.writeFileSync(e,...n);Qn.mkdirsSync(t),he.writeFileSync(e,...n)}var Be={outputFile:si(fi),outputFileSync:li};const{stringify:yi}=be,{outputFile:mi}=Be;async function di(e,n,t={}){const r=yi(n,t);await mi(e,r,t)}var hi=di;const{stringify:Si}=be,{outputFileSync:vi}=Be;function wi(e,n,t){const r=Si(n,t);vi(e,r,t)}var pi=wi;const Ei=W.fromPromise,b=ui;b.outputJson=Ei(hi),b.outputJsonSync=pi,b.outputJSON=b.outputJson,b.outputJSONSync=b.outputJsonSync,b.writeJSON=b.writeJson,b.writeJSONSync=b.writeJsonSync,b.readJSON=b.readJson,b.readJSONSync=b.readJsonSync;var $i=b;const ki=A,Je=N,gi=We.copy,Xn=Pe.remove,Fi=G.mkdirp,Di=ee.pathExists,Hn=oe;function Oi(e,n,t,r){typeof t=="function"&&(r=t,t={}),t=t||{};const i=t.overwrite||t.clobber||!1;Hn.checkPaths(e,n,"move",t,(o,c)=>{if(o)return r(o);const{srcStat:s,isChangingCase:f=!1}=c;Hn.checkParentPaths(e,s,n,"move",v=>{if(v)return r(v);if(Pi(n))return Zn(e,n,i,f,r);Fi(Je.dirname(n),u=>u?r(u):Zn(e,n,i,f,r))})})}function Pi(e){const n=Je.dirname(e);return Je.parse(n).root===n}function Zn(e,n,t,r,i){if(r)return qe(e,n,t,i);if(t)return Xn(n,o=>o?i(o):qe(e,n,t,i));Di(n,(o,c)=>o?i(o):c?i(new Error("dest already exists.")):qe(e,n,t,i))}function qe(e,n,t,r){ki.rename(e,n,i=>i?i.code!=="EXDEV"?r(i):_i(e,n,t,r):r())}function _i(e,n,t,r){gi(e,n,{overwrite:t,errorOnExist:!0},o=>o?r(o):Xn(e,r))}var Ni=Oi;const et=A,Ye=N,Ti=We.copySync,nt=Pe.removeSync,xi=G.mkdirpSync,tt=oe;function Ci(e,n,t){t=t||{};const r=t.overwrite||t.clobber||!1,{srcStat:i,isChangingCase:o=!1}=tt.checkPathsSync(e,n,"move",t);return tt.checkParentPathsSync(e,i,n,"move"),ji(n)||xi(Ye.dirname(n)),Ii(e,n,r,o)}function ji(e){const n=Ye.dirname(e);return Ye.parse(n).root===n}function Ii(e,n,t,r){if(r)return Ue(e,n,t);if(t)return nt(n),Ue(e,n,t);if(et.existsSync(n))throw new Error("dest already exists.");return Ue(e,n,t)}function Ue(e,n,t){try{et.renameSync(e,n)}catch(r){if(r.code!=="EXDEV")throw r;return Li(e,n,t)}}function Li(e,n,t){return Ti(e,n,{overwrite:t,errorOnExist:!0}),nt(e)}var Mi=Ci;const Ri=W.fromCallback;var Wi={move:Ri(Ni),moveSync:Mi},Ai={...H,...We,...gr,...Xr,...$i,...G,...Wi,...Be,...ee,...Pe};const rt=q(Ai),{default:U}=(()=>{const e=require("path");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})(),T=new Map;function bi(e){const{root:n,dir:t}=U.parse(e),r=t.split(n).slice(1).join("").split(U.sep);for(let o=0;o<r.length;o++){const c=[n,r.slice(0,o+1).join(U.sep)].join("");ct(c)}const i=rt.readFileSync(e).toString();it(e,i)}function Bi(e,n){const[t,r]=T.get(e);return Buffer.from(r)}function it(e,n,t){T.set(e,["file",n])}function Ji(e){return e===U.resolve(".")?!0:T.has(e)}function ot(e,n){const[t,r]=T.get(e)??["",""],i={isDirectory:()=>e===U.resolve(".")?!0:t==="dir",isFile:()=>T.has(e)&&t==="file",isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1,dev:0,ino:0,mode:0,nlink:0,uid:0,gid:0,rdev:0,size:0,blksize:0,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:new Date(0),mtime:new Date(0),ctime:new Date(0),birthtime:new Date(0)};return i.isBlockDevice(),i.isCharacterDevice(),i.isSymbolicLink(),i.isFIFO(),i.isSocket(),i}function qi(e,n){}class Yi extends Error{constructor(t){super(t);st(this,"code");this.code="ENOENT"}}function Ui(e,n){if(!T.has(e))throw new Yi("source path not found");for(const t of Array.from(T.keys()))if(t.includes(e)){const r=t.split(e).join(n),i=T.get(t)??["",""];T.delete(t),T.set(r,i)}}function Gi(e,n,t){if(T.has(n))throw Error("destination directory exists");for(const r of Array.from(T.keys()))if(r.includes(e)){const i=r.split(e).join(n);T.set(i,T.get(r)??["",""])}}function ct(e){if(ot(e).isFile())throw Error("file exists at destination");let n;const t=e.split(U.resolve(".")).join("").split(U.sep);for(let r=0;r<t.length;r++){const i=t.slice(0,r+1).join(U.sep);!T.has(`${U.resolve(".")}${i}`)&&i!==""&&(T.set(`${U.resolve(".")}${i}`,["dir",""]),n=n??`${U.resolve(".")}${i}`)}return n}function Vi(e){for(const n of Array.from(T.keys()))n.includes(e)&&T.delete(n)}function Ki(e){T.has(e)||T.set(e,["file",""])}const zi={existsSync:Ji,lstatSync:ot,chmodSync:qi,renameSync:Ui,readFileSync:Bi,copySync:Gi,removeSync:Vi,ensureFileSync:Ki,mkdirpSync:ct,outputFileSync:it,seedFile:bi},{default:ut}=(()=>{const e=require("path");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})();function Qi(e,n){const{existsSync:t,lstatSync:r,chmodSync:i,renameSync:o,readFileSync:c,copySync:s,removeSync:f,ensureFileSync:v,outputFileSync:u,mkdirpSync:y,seedFile:d}=e;if(d!==void 0&&n!==void 0)for(const a of n)m(a);function m(a){const l=p(a).value;d(l)}function h(a){return{success:!0,value:c(p(a).value),error:null}}function $(a,l){return u(p(a).value,l),{success:!0,error:null}}function w(a){const l=p(a).value;return t(l)?r(l).isFile()?{success:!0,value:!0,error:null}:{success:!1,value:!1,error:`checkIfFileExists: '${a}' is not a file.`}:{success:!0,value:!1,error:null}}function k(a){const l=p(a).value;return t(l)?r(l).isDirectory()?{success:!0,value:!0,error:null}:{success:!1,value:!1,error:`checkIfDirExists: '${a}' is not a directory.`}:{success:!0,value:!1,error:null}}function p(a){try{if(a===void 0)throw Error("Dir is undefined.");if(a.match(/^[.a-zA-Z0-9\-_/:\\]+$/g)===null)throw Error(`Dir contains unsupported characters. Received ${a}.`);return{success:!0,value:ut.normalize(ut.resolve(a)),error:null}}catch(l){return console.error(`Error resolving path: ${a}`),{success:!1,value:void 0,error:`Error resolving path: '${a}'. Received error: '${l}'`}}}function I(a){try{if(a===void 0)throw Error(`Function "createDir" expected a path. Recieved "${a}".`);const l=p(a).value;return{success:!0,value:y(l),error:null}}catch{return console.error(`Error creating dir: ${a}`),{success:!1,value:void 0,error:`Error creating dir: '${a}'`}}}function ne(a,l){const O=p(a).value;return v(O),l!==void 0&&i(O,l),{success:!0,error:null}}function ue(a){return p(a).value!==void 0&&k(a).value?(f(a),{success:!0,value:a,error:null}):(console.error(`Error deleting dir: ${a}`),{success:!1,value:void 0,error:`Error deleting dir: '${a}'`})}function Te(a){return a.map(l=>ue(p(l).value))}function Ge(a){return a!==null&&k(a).value?(console.error(`Cleaning up due to abort, directories created starting at: ${JSON.stringify(a)}`),ue(a),{success:!0,error:null}):(console.error("Cleaning up due to abort, no directory to clean up."),{success:!1,error:"Cleaning up due to abort, no directory to clean up."})}function Se(a,l){try{return o(p(a).value,p(l).value),{success:!0,value:"Successfully renamed the directory.",error:null}}catch(O){return console.error(O.code),{success:!1,value:void 0,error:`renameDir from '${a}' to '${l} failed.`}}}function S(a,l){try{return s(p(a).value,p(l).value,{overwrite:!1,errorOnExist:!0}),{success:!0,error:null}}catch{return{success:!1,error:`Error copying absolute from '${a}' to '${l}'`}}}return{getAbsolutePath:p,abortDirCreation:Ge,checkIfDirExists:k,copyDirAbs:S,createDir:I,renameDir:Se,rimrafDir:ue,rimrafDirs:Te,checkIfFileExists:w,readFile:h,writeFile:$,touchFile:ne}}return{use:Qi,default:rt,mock:zi}});
1
+ (function(a,o){typeof exports=="object"&&typeof module<"u"?module.exports=o():typeof define=="function"&&define.amd?define(o):(a=typeof globalThis<"u"?globalThis:a||self,a["fs-helpers"]=o())})(this,function(){"use strict";var Q=Object.defineProperty;var U=(a,o,s)=>o in a?Q(a,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[o]=s;var D=(a,o,s)=>(U(a,typeof o!="symbol"?o+"":o,s),s);const{default:a}=(()=>{const e=require("fs-extra");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})(),{default:o}=(()=>{const e=require("path");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})(),s=new Map;function E(e){const{root:n,dir:i}=o.parse(e),u=i.split(n).slice(1).join("").split(o.sep);for(let f=0;f<u.length;f++){const v=[n,u.slice(0,f+1).join(o.sep)].join("");b(v)}const c=a.readFileSync(e).toString();m(e,c)}function k(e,n){const[i,u]=s.get(e);return Buffer.from(u)}function m(e,n,i){s.set(e,["file",n])}function $(e){return e===o.resolve(".")?!0:s.has(e)}function h(e,n){const[i,u]=s.get(e)??["",""],c={isDirectory:()=>e===o.resolve(".")?!0:i==="dir",isFile:()=>s.has(e)&&i==="file",isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1,dev:0,ino:0,mode:0,nlink:0,uid:0,gid:0,rdev:0,size:0,blksize:0,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:new Date(0),mtime:new Date(0),ctime:new Date(0),birthtime:new Date(0)};return c.isBlockDevice(),c.isCharacterDevice(),c.isSymbolicLink(),c.isFIFO(),c.isSocket(),c}function F(e,n){}class x extends Error{constructor(i){super(i);D(this,"code");this.code="ENOENT"}}function _(e,n){if(!s.has(e))throw new x("source path not found");for(const i of Array.from(s.keys()))if(i.includes(e)){const u=i.split(e).join(n),c=s.get(i)??["",""];s.delete(i),s.set(u,c)}}function j(e,n,i){if(s.has(n))throw Error("destination directory exists");for(const u of Array.from(s.keys()))if(u.includes(e)){const c=u.split(e).join(n);s.set(c,s.get(u)??["",""])}}function b(e){if(h(e).isFile())throw Error("file exists at destination");let n;const i=e.split(o.resolve(".")).join("").split(o.sep);for(let u=0;u<i.length;u++){const c=i.slice(0,u+1).join(o.sep);!s.has(`${o.resolve(".")}${c}`)&&c!==""&&(s.set(`${o.resolve(".")}${c}`,["dir",""]),n=n??`${o.resolve(".")}${c}`)}return n}function w(e){for(const n of Array.from(s.keys()))n.includes(e)&&s.delete(n)}function M(e){s.has(e)||s.set(e,["file",""])}const O={existsSync:$,lstatSync:h,chmodSync:F,renameSync:_,readFileSync:k,copySync:j,removeSync:w,ensureFileSync:M,mkdirpSync:b,outputFileSync:m,seedFile:E},{default:T}=(()=>{const e=require("fs-extra");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})(),{default:S}=(()=>{const e=require("path");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})();function A(e,n){const{existsSync:i,lstatSync:u,chmodSync:c,renameSync:f,readFileSync:v,copySync:C,removeSync:I,ensureFileSync:N,outputFileSync:q,mkdirpSync:z,seedFile:g}=e;if(g!==void 0&&n!==void 0)for(const r of n)R(r);function R(r){const t=l(r).value;g(t)}function B(r){return{success:!0,value:v(l(r).value),error:null}}function L(r,t){return q(l(r).value,t),{success:!0,error:null}}function P(r){const t=l(r).value;return i(t)?u(t).isFile()?{success:!0,value:!0,error:null}:{success:!1,value:!1,error:`checkIfFileExists: '${r}' is not a file.`}:{success:!0,value:!1,error:null}}function y(r){const t=l(r).value;return i(t)?u(t).isDirectory()?{success:!0,value:!0,error:null}:{success:!1,value:!1,error:`checkIfDirExists: '${r}' is not a directory.`}:{success:!0,value:!1,error:null}}function l(r){try{if(r===void 0)throw Error("Dir is undefined.");if(r.match(/^[.a-zA-Z0-9\-_/:\\]+$/g)===null)throw Error(`Dir contains unsupported characters. Received ${r}.`);return{success:!0,value:S.normalize(S.resolve(r)),error:null}}catch(t){return console.error(`Error resolving path: ${r}`),{success:!1,value:void 0,error:`Error resolving path: '${r}'. Received error: '${t}'`}}}function V(r){try{if(r===void 0)throw Error(`Function "createDir" expected a path. Recieved "${r}".`);const t=l(r).value;return{success:!0,value:z(t),error:null}}catch{return console.error(`Error creating dir: ${r}`),{success:!1,value:void 0,error:`Error creating dir: '${r}'`}}}function J(r,t){const d=l(r).value;return N(d),t!==void 0&&c(d,t),{success:!0,error:null}}function p(r){return l(r).value!==void 0&&y(r).value?(I(r),{success:!0,value:r,error:null}):(console.error(`Error deleting dir: ${r}`),{success:!1,value:void 0,error:`Error deleting dir: '${r}'`})}function Z(r){return r.map(t=>p(l(t).value))}function G(r){return r!==null&&y(r).value?(console.error(`Cleaning up due to abort, directories created starting at: ${JSON.stringify(r)}`),p(r),{success:!0,error:null}):(console.error("Cleaning up due to abort, no directory to clean up."),{success:!1,error:"Cleaning up due to abort, no directory to clean up."})}function H(r,t){try{return f(l(r).value,l(t).value),{success:!0,value:"Successfully renamed the directory.",error:null}}catch(d){return console.error(d.code),{success:!1,value:void 0,error:`renameDir from '${r}' to '${t} failed.`}}}function K(r,t){try{return C(l(r).value,l(t).value,{overwrite:!1,errorOnExist:!0}),{success:!0,error:null}}catch{return{success:!1,error:`Error copying absolute from '${r}' to '${t}'`}}}return{getAbsolutePath:l,abortDirCreation:G,checkIfDirExists:y,copyDirAbs:K,createDir:V,renameDir:H,rimrafDir:p,rimrafDirs:Z,checkIfFileExists:P,readFile:B,writeFile:L,touchFile:J}}return{use:A,default:T,mock:O}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jestaubach/fs-helpers",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "type": "module",
5
5
  "main": "./dist/fs-helpers.umd.cjs",
6
6
  "module": "./dist/fs-helpers.js",
@@ -41,6 +41,8 @@
41
41
  "@types/mkdirp": "^1.0.2",
42
42
  "@types/node": "^18.7.1",
43
43
  "@vitest/coverage-istanbul": "^0.32.0",
44
+ "builtin-modules": "^3.3.0",
45
+ "lodash": "^4.17.21",
44
46
  "typescript": "^4.5.5",
45
47
  "vite": "^4.3.9",
46
48
  "vite-plugin-commonjs-externals": "^0.1.3",