@jestaubach/fs-helpers 0.2.9 → 0.2.11
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.
- package/LICENSE +21 -21
- package/dist/fs-helpers.js +1890 -0
- package/dist/fs-helpers.umd.cjs +7 -0
- package/dist/index.d.ts +27 -0
- package/dist/{src/mock.d.ts → mock.d.ts} +33 -32
- package/dist/{src/types.d.ts → types.d.ts} +19 -19
- package/package.json +13 -12
- package/dist/src/fsextra.d.ts +0 -2
- package/dist/src/fsextra.js +0 -16
- package/dist/src/fsextra.js.map +0 -1
- package/dist/src/index.d.ts +0 -26
- package/dist/src/index.js +0 -219
- package/dist/src/index.js.map +0 -1
- package/dist/src/mock.js +0 -123
- package/dist/src/mock.js.map +0 -1
- package/dist/src/types.js +0 -3
- package/dist/src/types.js.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
(function(Y,U){typeof exports=="object"&&typeof module<"u"?module.exports=U():typeof define=="function"&&define.amd?define(U):(Y=typeof globalThis<"u"?globalThis:Y||self,Y["fs-helpers"]=U())})(this,function(){"use strict";var Qi=Object.defineProperty;var Xi=(Y,U,X)=>U in Y?Qi(Y,U,{enumerable:!0,configurable:!0,writable:!0,value:X}):Y[U]=X;var ut=(Y,U,X)=>(Xi(Y,typeof U!="symbol"?U+"":U,X),X);var Y=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function U(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 J={},_=X(Object.freeze(Object.defineProperty({__proto__:null,default:J},Symbol.toStringTag,{value:"Module"})));var V=_,st=process.cwd,ve=null,at=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return ve||(ve=st.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 ft=lt;function lt(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(){}),at==="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=_.Stream,yt=mt;function mt(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 dt=St,ht=Object.getPrototypeOf||function(e){return e.__proto__};function St(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var n={__proto__:ht(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=_,vt=ft,wt=yt,pt=dt,we=_,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 Et(){}function ze(e,n){Object.defineProperty(e,j,{get:function(){return n}})}var Z=Et;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 $t=Y[j]||[];ze(D,$t),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]),_.equal(D[j].length,0)})}Y[j]||ze(Y,D[j]);var A=xe(pt(D));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!D.__patched&&(A=xe(D),D.__patched=!0);function xe(e){vt(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,N){return n(L,C,function(F){F&&(F.code==="EMFILE"||F.code==="ENFILE")?te([O,[L,C,P],F,N||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,N,F,M){return r(C,P,N,function(g){g&&(g.code==="EMFILE"||g.code==="ENFILE")?te([L,[C,P,N,F],g,M||Date.now(),Date.now()]):typeof F=="function"&&F.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,N,F,M){return o(C,P,N,function(g){g&&(g.code==="EMFILE"||g.code==="ENFILE")?te([L,[C,P,N,F],g,M||Date.now(),Date.now()]):typeof F=="function"&&F.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,N,F,M){return s(C,P,N,function(g){g&&(g.code==="EMFILE"||g.code==="ENFILE")?te([L,[C,P,N,F],g,M||Date.now(),Date.now()]):typeof F=="function"&&F.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,N,F,M){return v(P,L(P,N,F,M))}:function(P,N,F,M){return v(P,N,L(P,N,F,M))};return O(S,a,l);function L(C,P,N,F){return function(M,g){M&&(M.code==="EMFILE"||M.code==="ENFILE")?te([O,[C,P,N],M,F||Date.now(),Date.now()]):(g&&g.sort&&g.sort(),typeof N=="function"&&N.call(this,M,g))}}}if(process.version.substr(0,4)==="v0.8"){var d=wt(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,N,F,M){return Ge(C,P,N,function(g,no){g&&(g.code==="EMFILE"||g.code==="ENFILE")?te([L,[C,P,N,F],g,M||Date.now(),Date.now()]):typeof F=="function"&&F.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 kt=_;Xe.checkPath=function(n){if(process.platform==="win32"&&/[<>:"|?*]/.test(n.replace(kt.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:gt,makeDirSync:Ie}=je,Le=Ft(gt);var G={mkdirs:Le,mkdirsSync:Ie,mkdirp:Le,mkdirpSync:Ie,ensureDir:Le,ensureDirSync:Ie};const Dt=W.fromPromise,nn=H;function Ot(e){return nn.access(e).then(()=>!0).catch(()=>!1)}var ee={pathExists:Dt(Ot),pathExistsSync:nn.existsSync};const re=A;function Pt(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:Pt,utimesMillisSync:Nt};const ie=H,x=_,_t=_;function Tt(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 xt(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 Ct(e,n,t,r,i){_t.callbackify(Tt)(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 jt(e,n,t,r){const{srcStat:i,destStat:o}=xt(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:Ct,checkPathsSync:jt,checkParentPaths:rn,checkParentPathsSync:on,isSrcSubdir:Me,areIdentical:se};const B=A,ae=_,It=G.mkdirs,Lt=ee.pathExists,Mt=tn.utimesMillis,fe=oe;function Rt(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);Lt(o,(c,s)=>{if(c)return i(c);if(s)return ke(e,n,t,r,i);It(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 Wt(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()?qt(s,e,n,t,r,i):s.isFile()||s.isCharacterDevice()||s.isBlockDevice()?At(s,e,n,t,r,i):s.isSymbolicLink()?Kt(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 At(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):Fe(t,e.mode,i))}function Jt(e,n,t,r){return Bt(e)?Yt(t,e,i=>i?r(i):an(e,n,t,r)):an(e,n,t,r)}function Bt(e){return(e&128)===0}function Yt(e,n,t){return Fe(e,n|128,t)}function an(e,n,t,r){Ut(n,t,i=>i?r(i):Fe(t,e,r))}function Fe(e,n,t){return B.chmod(e,n,t)}function Ut(e,n,t){B.stat(e,(r,i)=>r?t(r):Mt(n,i.atime,i.mtime,t))}function qt(e,n,t,r,i,o){return n?fn(t,r,i,o):Gt(e.mode,t,r,i,o)}function Gt(e,n,t,r,i){B.mkdir(t,o=>{if(o)return i(o);fn(n,t,r,c=>c?i(c):Fe(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?Vt(e,o,n,t,r,i):i()}function Vt(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;Wt(u,c,s,i,y=>y?o(y):ln(e,t,r,i,o))})}function Kt(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}'.`)):zt(c,t,i)));else return B.symlink(c,t,i)})}function zt(e,n,t){B.unlink(n,r=>r?t(r):B.symlink(e,n,t))}var Qt=Rt;const R=A,le=_,Xt=G.mkdirsSync,Ht=tn.utimesMillisSync,ye=oe;function Zt(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"),er(i,e,n,t)}function er(e,n,t,r){if(r.filter&&!r.filter(n,t))return;const i=le.dirname(t);return R.existsSync(i)||Xt(i),yn(e,n,t,r)}function nr(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 sr(o,e,n,t,r);if(o.isFile()||o.isCharacterDevice()||o.isBlockDevice())return tr(o,e,n,t,r);if(o.isSymbolicLink())return lr(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 tr(e,n,t,r,i){return n?rr(e,t,r,i):mn(e,t,r,i)}function rr(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&&ir(e.mode,n,t),Re(t,e.mode)}function ir(e,n,t){return or(e)&&cr(t,e),ur(n,t)}function or(e){return(e&128)===0}function cr(e,n){return Re(e,n|128)}function Re(e,n){return R.chmodSync(e,n)}function ur(e,n){const t=R.statSync(e);return Ht(n,t.atime,t.mtime)}function sr(e,n,t,r,i){return n?dn(t,r,i):ar(e.mode,t,r,i)}function ar(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=>fr(r,e,n,t))}function fr(e,n,t,r){const i=le.join(n,e),o=le.join(t,e),{destStat:c}=ye.checkPathsSync(i,o,"copy",r);return nr(c,i,o,r)}function lr(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 yr(i,t)}else return R.symlinkSync(i,t)}function yr(e,n){return R.unlinkSync(n),R.symlinkSync(e,n)}var mr=Zt;const dr=W.fromCallback;var We={copy:dr(Qt),copySync:mr};const hn=A,Sn=_,E=_,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 ge(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):ge(e,n,o,t);if(o.code==="EISDIR")return ge(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()?ge(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 ge(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")?hr(e,n,r):i&&i.code==="ENOTDIR"?r(t):r(i)})}function hr(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")Sr(e,n);else if(r.code!=="ENOENT")throw r}}function Sr(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 vr=Ae;Ae.sync=$n;const Oe=A,wr=W.fromCallback,kn=vr;function pr(e,n){if(Oe.rm)return Oe.rm(e,{recursive:!0,force:!0},n);kn(e,n)}function Er(e){if(Oe.rmSync)return Oe.rmSync(e,{recursive:!0,force:!0});kn.sync(e)}var Pe={remove:wr(pr),removeSync:Er};const $r=W.fromPromise,Fn=H,gn=_,Dn=G,On=Pe,Pn=$r(async function(n){let t;try{t=await Fn.readdir(n)}catch{return Dn.mkdirs(n)}return Promise.all(t.map(r=>On.remove(gn.join(n,r))))});function Nn(e){let n;try{n=Fn.readdirSync(e)}catch{return Dn.mkdirsSync(e)}n.forEach(t=>{t=gn.join(e,t),On.removeSync(t)})}var kr={emptyDirSync:Nn,emptydirSync:Nn,emptyDir:Pn,emptydir:Pn};const Fr=W.fromCallback,_n=_,K=A,Tn=G;function gr(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=_n.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 Dr(e){let n;try{n=K.statSync(e)}catch{}if(n&&n.isFile())return;const t=_n.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 Or={createFile:Fr(gr),createFileSync:Dr};const Pr=W.fromCallback,xn=_,z=A,Cn=G,Nr=ee.pathExists,{areIdentical:jn}=oe;function _r(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 Tr(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 xr={createLink:Pr(_r),createLinkSync:Tr};const Q=_,de=A,Cr=ee.pathExists;function jr(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 Cr(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 Ir(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 Lr={symlinkPaths:jr,symlinkPathsSync:Ir};const In=A;function Mr(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 Rr(e,n){let t;if(n)return n;try{t=In.lstatSync(e)}catch{return"file"}return t&&t.isDirectory()?"dir":"file"}var Wr={symlinkType:Mr,symlinkTypeSync:Rr};const Ar=W.fromCallback,Ln=_,q=H,Mn=G,br=Mn.mkdirs,Jr=Mn.mkdirsSync,Rn=Lr,Br=Rn.symlinkPaths,Yr=Rn.symlinkPathsSync,Wn=Wr,Ur=Wn.symlinkType,qr=Wn.symlinkTypeSync,Gr=ee.pathExists,{areIdentical:An}=oe;function Vr(e,n,t,r){r=typeof t=="function"?t:r,t=typeof t=="function"?!1:t,q.lstat(n,(i,o)=>{!i&&o.isSymbolicLink()?Promise.all([q.stat(e),q.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){Br(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);Gr(f,(v,u)=>{if(v)return r(v);if(u)return q.symlink(e,n,s,r);br(f,y=>{if(y)return r(y);q.symlink(e,n,s,r)})})})})}function Kr(e,n,t){let r;try{r=q.lstatSync(n)}catch{}if(r&&r.isSymbolicLink()){const s=q.statSync(e),f=q.statSync(n);if(An(s,f))return}const i=Yr(e,n);e=i.toDst,t=qr(i.toCwd,t);const o=Ln.dirname(n);return q.existsSync(o)||Jr(o),q.symlinkSync(e,n,t)}var zr={createSymlink:Ar(Vr),createSymlinkSync:Kr};const{createFile:Jn,createFileSync:Bn}=Or,{createLink:Yn,createLinkSync:Un}=xr,{createSymlink:qn,createSymlinkSync:Gn}=zr;var Qr={createFile:Jn,createFileSync:Bn,ensureFile:Jn,ensureFileSync:Bn,createLink:Yn,createLinkSync:Un,ensureLink:Yn,ensureLinkSync:Un,createSymlink:qn,createSymlinkSync:Gn,ensureSymlink:qn,ensureSymlinkSync:Gn};function Xr(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 Hr(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e.replace(/^\uFEFF/,"")}var be={stringify:Xr,stripBom:Hr};let ce;try{ce=A}catch{ce=_}const Ne=W,{stringify:Vn,stripBom:Kn}=be;async function Zr(e,n={}){typeof n=="string"&&(n={encoding:n});const t=n.fs||ce,r="throws"in n?n.throws:!0;let i=await Ne.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 ei=Ne.fromPromise(Zr);function ni(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 ti(e,n,t={}){const r=t.fs||ce,i=Vn(n,t);await Ne.fromCallback(r.writeFile)(e,i,t)}const ri=Ne.fromPromise(ti);function ii(e,n,t={}){const r=t.fs||ce,i=Vn(n,t);return r.writeFileSync(e,i,t)}var oi={readFile:ei,readFileSync:ni,writeFile:ri,writeFileSync:ii};const _e=oi;var ci={readJson:_e.readFile,readJsonSync:_e.readFileSync,writeJson:_e.writeFile,writeJsonSync:_e.writeFileSync};const ui=W.fromCallback,he=A,zn=_,Qn=G,si=ee.pathExists;function ai(e,n,t,r){typeof t=="function"&&(r=t,t="utf8");const i=zn.dirname(e);si(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 fi(e,...n){const t=zn.dirname(e);if(he.existsSync(t))return he.writeFileSync(e,...n);Qn.mkdirsSync(t),he.writeFileSync(e,...n)}var Je={outputFile:ui(ai),outputFileSync:fi};const{stringify:li}=be,{outputFile:yi}=Je;async function mi(e,n,t={}){const r=li(n,t);await yi(e,r,t)}var di=mi;const{stringify:hi}=be,{outputFileSync:Si}=Je;function vi(e,n,t){const r=hi(n,t);Si(e,r,t)}var wi=vi;const pi=W.fromPromise,b=ci;b.outputJson=pi(di),b.outputJsonSync=wi,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 Ei=b;const $i=A,Be=_,ki=We.copy,Xn=Pe.remove,Fi=G.mkdirp,gi=ee.pathExists,Hn=oe;function Di(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(Oi(n))return Zn(e,n,i,f,r);Fi(Be.dirname(n),u=>u?r(u):Zn(e,n,i,f,r))})})}function Oi(e){const n=Be.dirname(e);return Be.parse(n).root===n}function Zn(e,n,t,r,i){if(r)return Ye(e,n,t,i);if(t)return Xn(n,o=>o?i(o):Ye(e,n,t,i));gi(n,(o,c)=>o?i(o):c?i(new Error("dest already exists.")):Ye(e,n,t,i))}function Ye(e,n,t,r){$i.rename(e,n,i=>i?i.code!=="EXDEV"?r(i):Pi(e,n,t,r):r())}function Pi(e,n,t,r){ki(e,n,{overwrite:t,errorOnExist:!0},o=>o?r(o):Xn(e,r))}var Ni=Di;const et=A,Ue=_,_i=We.copySync,nt=Pe.removeSync,Ti=G.mkdirpSync,tt=oe;function xi(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"),Ci(n)||Ti(Ue.dirname(n)),ji(e,n,r,o)}function Ci(e){const n=Ue.dirname(e);return Ue.parse(n).root===n}function ji(e,n,t,r){if(r)return qe(e,n,t);if(t)return nt(n),qe(e,n,t);if(et.existsSync(n))throw new Error("dest already exists.");return qe(e,n,t)}function qe(e,n,t){try{et.renameSync(e,n)}catch(r){if(r.code!=="EXDEV")throw r;return Ii(e,n,t)}}function Ii(e,n,t){return _i(e,n,{overwrite:t,errorOnExist:!0}),nt(e)}var Li=xi;const Mi=W.fromCallback;var Ri={move:Mi(Ni),moveSync:Li},Wi={...H,...We,...kr,...Qr,...Ei,...G,...Ri,...Je,...ee,...Pe};const rt=U(Wi),T=new Map;function Ai(e){const{root:n,dir:t}=J.parse(e),r=t.split(n).slice(1).join("").split(J.sep);for(let o=0;o<r.length;o++){const c=[n,r.slice(0,o+1).join(J.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===J.resolve(".")?!0:T.has(e)}function ot(e,n){const[t,r]=T.get(e)??["",""],i={isDirectory:()=>e===J.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 Bi(e,n){}class Yi extends Error{constructor(t){super(t);ut(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 qi(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(J.resolve(".")).join("").split(J.sep);for(let r=0;r<t.length;r++){const i=t.slice(0,r+1).join(J.sep);!T.has(`${J.resolve(".")}${i}`)&&i!==""&&(T.set(`${J.resolve(".")}${i}`,["dir",""]),n=n??`${J.resolve(".")}${i}`)}return n}function Gi(e){for(const n of Array.from(T.keys()))n.includes(e)&&T.delete(n)}function Vi(e){T.has(e)||T.set(e,["file",""])}const Ki={existsSync:Ji,lstatSync:ot,chmodSync:Bi,renameSync:Ui,readFileSync:bi,copySync:qi,removeSync:Gi,ensureFileSync:Vi,mkdirpSync:ct,outputFileSync:it,seedFile:Ai};function zi(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:J.normalize(J.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:zi,default:rt,mock:Ki}});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import fsExtra from 'fs-extra';
|
|
4
|
+
declare function use(fsLibrary: any, seedFiles?: string[]): any;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
use: typeof use;
|
|
7
|
+
default: typeof fsExtra;
|
|
8
|
+
mock: {
|
|
9
|
+
existsSync: (filePath: fsExtra.PathLike) => boolean;
|
|
10
|
+
lstatSync: (filePath: fsExtra.PathLike, _options?: (fsExtra.StatOptions & {
|
|
11
|
+
bigint?: false | undefined;
|
|
12
|
+
}) | undefined) => fsExtra.Stats;
|
|
13
|
+
chmodSync: (_filePath: fsExtra.PathLike, _mode: fsExtra.Mode) => void;
|
|
14
|
+
renameSync: (oldPath: fsExtra.PathLike, newPath: fsExtra.PathLike) => void;
|
|
15
|
+
readFileSync: (filePath: string, _options?: {
|
|
16
|
+
encoding: BufferEncoding;
|
|
17
|
+
flag?: string | undefined;
|
|
18
|
+
} | BufferEncoding | undefined) => Buffer;
|
|
19
|
+
copySync: (src: string, dest: string, _options?: fsExtra.CopyOptionsSync | undefined) => void;
|
|
20
|
+
removeSync: (filePath: string) => void;
|
|
21
|
+
ensureFileSync: (filename: string) => void;
|
|
22
|
+
mkdirpSync: (dir: string) => any;
|
|
23
|
+
outputFileSync: (filename: string, data: string, _options?: string | fsExtra.WriteFileOptions | undefined) => void;
|
|
24
|
+
seedFile: (fileName: string) => void;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export default _default;
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
declare function
|
|
10
|
-
declare function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
declare function
|
|
15
|
-
declare function
|
|
16
|
-
declare function
|
|
17
|
-
declare function
|
|
18
|
-
declare function
|
|
19
|
-
declare
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
declare function seedFile(fileName: string): void;
|
|
5
|
+
declare function readFileSync(filePath: string, _options?: {
|
|
6
|
+
encoding: BufferEncoding;
|
|
7
|
+
flag?: string;
|
|
8
|
+
} | BufferEncoding): Buffer;
|
|
9
|
+
declare function outputFileSync(filename: string, data: string, _options?: string | fs.WriteFileOptions): void;
|
|
10
|
+
declare function existsSync(filePath: fs.PathLike): boolean;
|
|
11
|
+
declare function lstatSync(filePath: fs.PathLike, _options?: fs.StatOptions & {
|
|
12
|
+
bigint?: false;
|
|
13
|
+
}): fs.Stats;
|
|
14
|
+
declare function chmodSync(_filePath: fs.PathLike, _mode: fs.Mode): void;
|
|
15
|
+
declare function renameSync(oldPath: fs.PathLike, newPath: fs.PathLike): void;
|
|
16
|
+
declare function copySync(src: string, dest: string, _options?: fs.CopyOptionsSync): void;
|
|
17
|
+
declare function mkdirpSync(dir: string): any;
|
|
18
|
+
declare function removeSync(filePath: string): void;
|
|
19
|
+
declare function ensureFileSync(filename: string): void;
|
|
20
|
+
declare const _default: {
|
|
21
|
+
existsSync: typeof existsSync;
|
|
22
|
+
lstatSync: typeof lstatSync;
|
|
23
|
+
chmodSync: typeof chmodSync;
|
|
24
|
+
renameSync: typeof renameSync;
|
|
25
|
+
readFileSync: typeof readFileSync;
|
|
26
|
+
copySync: typeof copySync;
|
|
27
|
+
removeSync: typeof removeSync;
|
|
28
|
+
ensureFileSync: typeof ensureFileSync;
|
|
29
|
+
mkdirpSync: typeof mkdirpSync;
|
|
30
|
+
outputFileSync: typeof outputFileSync;
|
|
31
|
+
seedFile: typeof seedFile;
|
|
32
|
+
};
|
|
33
|
+
export default _default;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
success: boolean;
|
|
5
|
-
error?: string;
|
|
6
|
-
};
|
|
7
|
-
interface RetBuffer extends RetVal {
|
|
8
|
-
value?: Buffer;
|
|
9
|
-
}
|
|
10
|
-
interface RetString extends RetVal {
|
|
11
|
-
value?: string;
|
|
12
|
-
}
|
|
13
|
-
interface RetBool extends RetVal {
|
|
14
|
-
value?: boolean;
|
|
15
|
-
}
|
|
16
|
-
interface RetPath extends RetVal {
|
|
17
|
-
value?: Path;
|
|
18
|
-
}
|
|
19
|
-
export { Path, RetBool, RetString, RetVal, RetPath, RetBuffer, };
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
type Path = string;
|
|
3
|
+
type RetVal = {
|
|
4
|
+
success: boolean;
|
|
5
|
+
error?: string | null;
|
|
6
|
+
};
|
|
7
|
+
interface RetBuffer extends RetVal {
|
|
8
|
+
value?: Buffer;
|
|
9
|
+
}
|
|
10
|
+
interface RetString extends RetVal {
|
|
11
|
+
value?: string;
|
|
12
|
+
}
|
|
13
|
+
interface RetBool extends RetVal {
|
|
14
|
+
value?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface RetPath extends RetVal {
|
|
17
|
+
value?: Path;
|
|
18
|
+
}
|
|
19
|
+
export type { Path, RetBool, RetString, RetVal, RetPath, RetBuffer, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jestaubach/fs-helpers",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/fs-helpers.umd.cjs",
|
|
6
|
+
"module": "./dist/fs-helpers.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
4
8
|
"description": "wrapper around fs-extra",
|
|
5
9
|
"keywords": [],
|
|
6
10
|
"homepage": "https://github.com/JEStaubach/fs-helpers",
|
|
@@ -21,16 +25,12 @@
|
|
|
21
25
|
],
|
|
22
26
|
"license": "MIT",
|
|
23
27
|
"private": false,
|
|
24
|
-
"main": "dist/src/index.js",
|
|
25
|
-
"types": "dist/src/index.d.ts",
|
|
26
28
|
"files": [
|
|
27
|
-
"dist
|
|
29
|
+
"dist"
|
|
28
30
|
],
|
|
29
31
|
"scripts": {
|
|
30
|
-
"build": "tsc &&
|
|
31
|
-
"test": "
|
|
32
|
-
"bump": "npm version patch",
|
|
33
|
-
"release": "git push --tags && npm publish"
|
|
32
|
+
"build": "tsc && vite build",
|
|
33
|
+
"test": "vitest run --coverage"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"fs-extra": "^10.0.0",
|
|
@@ -38,11 +38,12 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/fs-extra": "^9.0.13",
|
|
41
|
-
"@types/jest": "^28.1.6",
|
|
42
41
|
"@types/mkdirp": "^1.0.2",
|
|
43
42
|
"@types/node": "^18.7.1",
|
|
44
|
-
"@
|
|
45
|
-
"
|
|
46
|
-
"
|
|
43
|
+
"@vitest/coverage-istanbul": "^0.32.0",
|
|
44
|
+
"typescript": "^4.5.5",
|
|
45
|
+
"vite": "^4.3.9",
|
|
46
|
+
"vite-plugin-dts": "^2.3.0",
|
|
47
|
+
"vitest": "^0.32.0"
|
|
47
48
|
}
|
|
48
49
|
}
|
package/dist/src/fsextra.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { existsSync, lstatSync, chmodSync, renameSync, readFileSync, copySync, removeSync, ensureFileSync, outputFileSync, mkdirpSync } from './mock';
|
|
2
|
-
export { existsSync, lstatSync, chmodSync, renameSync, readFileSync, copySync, mkdirpSync, removeSync, ensureFileSync, outputFileSync };
|
package/dist/src/fsextra.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.outputFileSync = exports.ensureFileSync = exports.removeSync = exports.mkdirpSync = exports.copySync = exports.readFileSync = exports.renameSync = exports.chmodSync = exports.lstatSync = exports.existsSync = void 0;
|
|
4
|
-
//import { existsSync, lstatSync, chmodSync, renameSync, readFileSync, copySync, removeSync, ensureFileSync, outputFileSync, mkdirpSync } from 'fs-extra';
|
|
5
|
-
const mock_1 = require("./mock");
|
|
6
|
-
Object.defineProperty(exports, "existsSync", { enumerable: true, get: function () { return mock_1.existsSync; } });
|
|
7
|
-
Object.defineProperty(exports, "lstatSync", { enumerable: true, get: function () { return mock_1.lstatSync; } });
|
|
8
|
-
Object.defineProperty(exports, "chmodSync", { enumerable: true, get: function () { return mock_1.chmodSync; } });
|
|
9
|
-
Object.defineProperty(exports, "renameSync", { enumerable: true, get: function () { return mock_1.renameSync; } });
|
|
10
|
-
Object.defineProperty(exports, "readFileSync", { enumerable: true, get: function () { return mock_1.readFileSync; } });
|
|
11
|
-
Object.defineProperty(exports, "copySync", { enumerable: true, get: function () { return mock_1.copySync; } });
|
|
12
|
-
Object.defineProperty(exports, "removeSync", { enumerable: true, get: function () { return mock_1.removeSync; } });
|
|
13
|
-
Object.defineProperty(exports, "ensureFileSync", { enumerable: true, get: function () { return mock_1.ensureFileSync; } });
|
|
14
|
-
Object.defineProperty(exports, "outputFileSync", { enumerable: true, get: function () { return mock_1.outputFileSync; } });
|
|
15
|
-
Object.defineProperty(exports, "mkdirpSync", { enumerable: true, get: function () { return mock_1.mkdirpSync; } });
|
|
16
|
-
//# sourceMappingURL=fsextra.js.map
|
package/dist/src/fsextra.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fsextra.js","sourceRoot":"","sources":["../../src/fsextra.ts"],"names":[],"mappings":";;;AAAA,0JAA0J;AAC1J,iCAAsJ;AAG7I,2FAHA,iBAAU,OAGA;AAAE,0FAHA,gBAAS,OAGA;AAAE,0FAHA,gBAAS,OAGA;AAAE,2FAHA,iBAAU,OAGA;AAAE,6FAHA,mBAAY,OAGA;AAAE,yFAHA,eAAQ,OAGA;AAAc,2FAHZ,iBAAU,OAGY;AAAE,+FAHZ,qBAAc,OAGY;AAAE,+FAHZ,qBAAc,OAGY;AAAtD,2FAH4C,iBAAU,OAG5C"}
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import fsExtra from 'fs-extra';
|
|
3
|
-
declare function use(fsLibrary: any, seedFiles?: string[]): any;
|
|
4
|
-
declare const _default: {
|
|
5
|
-
use: typeof use;
|
|
6
|
-
default: typeof fsExtra;
|
|
7
|
-
mock: {
|
|
8
|
-
existsSync: (filePath: fsExtra.PathLike) => boolean;
|
|
9
|
-
lstatSync: (filePath: fsExtra.PathLike, options?: fsExtra.StatOptions & {
|
|
10
|
-
bigint?: false;
|
|
11
|
-
}) => fsExtra.Stats;
|
|
12
|
-
chmodSync: (filePath: fsExtra.PathLike, mode: fsExtra.Mode) => void;
|
|
13
|
-
renameSync: (oldPath: fsExtra.PathLike, newPath: fsExtra.PathLike) => void;
|
|
14
|
-
readFileSync: (filePath: string, _options?: BufferEncoding | {
|
|
15
|
-
encoding: BufferEncoding;
|
|
16
|
-
flag?: string;
|
|
17
|
-
}) => Buffer;
|
|
18
|
-
copySync: (src: string, dest: string, options?: fsExtra.CopyOptionsSync) => void;
|
|
19
|
-
removeSync: (filePath: string) => void;
|
|
20
|
-
ensureFileSync: (filename: string) => void;
|
|
21
|
-
mkdirpSync: (dir: string) => any;
|
|
22
|
-
outputFileSync: (filename: string, data: string, options?: string | fsExtra.WriteFileOptions) => void;
|
|
23
|
-
seedFile: (fileName: string) => void;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export default _default;
|
package/dist/src/index.js
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const mock_1 = __importDefault(require("./mock"));
|
|
9
|
-
function use(fsLibrary, seedFiles) {
|
|
10
|
-
const { existsSync, lstatSync, chmodSync, renameSync, readFileSync, copySync, removeSync, ensureFileSync, outputFileSync, mkdirpSync, seedFile } = fsLibrary;
|
|
11
|
-
if (seedFile !== undefined && seedFiles !== undefined) {
|
|
12
|
-
for (const file of seedFiles) {
|
|
13
|
-
mockExistingFile(file);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function mockExistingFile(fileName) {
|
|
17
|
-
const absPath = getAbsolutePath(fileName).value;
|
|
18
|
-
if (seedFile !== undefined) {
|
|
19
|
-
seedFile(absPath);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function readFile(fileName) {
|
|
23
|
-
return {
|
|
24
|
-
success: true,
|
|
25
|
-
value: readFileSync(getAbsolutePath(fileName).value),
|
|
26
|
-
error: null,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function writeFile(fileName, data) {
|
|
30
|
-
outputFileSync(getAbsolutePath(fileName).value, data);
|
|
31
|
-
return {
|
|
32
|
-
success: true,
|
|
33
|
-
error: null
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function checkIfFileExists(filePath) {
|
|
37
|
-
const absPath = getAbsolutePath(filePath).value;
|
|
38
|
-
if (!existsSync(absPath)) {
|
|
39
|
-
return {
|
|
40
|
-
success: true,
|
|
41
|
-
value: false,
|
|
42
|
-
error: null,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
if (!lstatSync(absPath).isFile()) {
|
|
46
|
-
return {
|
|
47
|
-
success: false,
|
|
48
|
-
value: false,
|
|
49
|
-
error: `checkIfFileExists: '${filePath}' is not a file.`,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
success: true,
|
|
54
|
-
value: true,
|
|
55
|
-
error: null,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function checkIfDirExists(dir) {
|
|
59
|
-
const absDir = getAbsolutePath(dir).value;
|
|
60
|
-
if (!existsSync(absDir)) {
|
|
61
|
-
return {
|
|
62
|
-
success: true,
|
|
63
|
-
value: false,
|
|
64
|
-
error: null,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
if (!lstatSync(absDir).isDirectory()) {
|
|
68
|
-
return {
|
|
69
|
-
success: false,
|
|
70
|
-
value: false,
|
|
71
|
-
error: `checkIfDirExists: '${dir}' is not a directory.`,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
success: true,
|
|
76
|
-
value: true,
|
|
77
|
-
error: null,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
function getAbsolutePath(dir) {
|
|
81
|
-
try {
|
|
82
|
-
if (dir.match(/^[.a-zA-Z0-9\-_/:\\]+$/g) === null) {
|
|
83
|
-
throw Error(`Dir contains unsupported characters. Received ${dir}.`);
|
|
84
|
-
}
|
|
85
|
-
const absPath = path_1.default.normalize(path_1.default.resolve(dir));
|
|
86
|
-
return {
|
|
87
|
-
success: true,
|
|
88
|
-
value: absPath,
|
|
89
|
-
error: null,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
catch (err) {
|
|
93
|
-
console.error(`Error resolving path: ${dir}`);
|
|
94
|
-
return {
|
|
95
|
-
success: false,
|
|
96
|
-
value: undefined,
|
|
97
|
-
error: `Error resolving path: '${dir}'. Received error: '${err}'`,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function createDir(dir) {
|
|
102
|
-
try {
|
|
103
|
-
if (dir === undefined) {
|
|
104
|
-
throw Error(`Function "createDir" expected a path. Recieved "${dir}".`);
|
|
105
|
-
}
|
|
106
|
-
const absDir = getAbsolutePath(dir).value;
|
|
107
|
-
return {
|
|
108
|
-
success: true,
|
|
109
|
-
value: mkdirpSync(absDir),
|
|
110
|
-
error: null,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
catch (err) {
|
|
114
|
-
console.error(`Error creating dir: ${dir}`);
|
|
115
|
-
return {
|
|
116
|
-
success: false,
|
|
117
|
-
value: undefined,
|
|
118
|
-
error: `Error creating dir: '${dir}'`,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
function touchFile(filePath, perms) {
|
|
123
|
-
const absPath = getAbsolutePath(filePath).value;
|
|
124
|
-
ensureFileSync(absPath);
|
|
125
|
-
if (perms !== undefined) {
|
|
126
|
-
chmodSync(absPath, perms);
|
|
127
|
-
}
|
|
128
|
-
return {
|
|
129
|
-
success: true,
|
|
130
|
-
error: null,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
function rimrafDir(dir) {
|
|
134
|
-
const absPath = getAbsolutePath(dir).value;
|
|
135
|
-
if (absPath !== undefined && checkIfDirExists(dir).value) {
|
|
136
|
-
removeSync(dir);
|
|
137
|
-
return {
|
|
138
|
-
success: true,
|
|
139
|
-
value: dir,
|
|
140
|
-
error: null,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
console.error(`Error deleting dir: ${dir}`);
|
|
144
|
-
return {
|
|
145
|
-
success: false,
|
|
146
|
-
value: undefined,
|
|
147
|
-
error: `Error deleting dir: '${dir}'`,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function rimrafDirs(dirs) {
|
|
151
|
-
return dirs.map((dir) => {
|
|
152
|
-
return rimrafDir(getAbsolutePath(dir).value);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
function abortDirCreation(dir) {
|
|
156
|
-
if (dir !== null && checkIfDirExists(dir).value) {
|
|
157
|
-
console.error(`Cleaning up due to abort, directories created starting at: ${JSON.stringify(dir)}`);
|
|
158
|
-
rimrafDir(dir);
|
|
159
|
-
return {
|
|
160
|
-
success: true,
|
|
161
|
-
error: null,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
console.error(`Cleaning up due to abort, no directory to clean up.`);
|
|
165
|
-
return {
|
|
166
|
-
success: false,
|
|
167
|
-
error: `Cleaning up due to abort, no directory to clean up.`,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
function renameDir(oldPath, newPath) {
|
|
171
|
-
try {
|
|
172
|
-
renameSync(getAbsolutePath(oldPath).value, getAbsolutePath(newPath).value);
|
|
173
|
-
return {
|
|
174
|
-
success: true,
|
|
175
|
-
value: `Successfully renamed the directory.`,
|
|
176
|
-
error: null,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
catch (err) {
|
|
180
|
-
console.error(err.code);
|
|
181
|
-
return {
|
|
182
|
-
success: false,
|
|
183
|
-
value: undefined,
|
|
184
|
-
error: `renameDir from '${oldPath}' to '${newPath} failed.`
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
function copyDirAbs(src, dest) {
|
|
189
|
-
try {
|
|
190
|
-
copySync(getAbsolutePath(src).value, getAbsolutePath(dest).value, { overwrite: false, errorOnExist: true });
|
|
191
|
-
return {
|
|
192
|
-
success: true,
|
|
193
|
-
error: null,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
catch (err) {
|
|
197
|
-
return {
|
|
198
|
-
success: false,
|
|
199
|
-
error: `Error copying absolute from '${src}' to '${dest}'`,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return {
|
|
204
|
-
getAbsolutePath,
|
|
205
|
-
abortDirCreation,
|
|
206
|
-
checkIfDirExists,
|
|
207
|
-
copyDirAbs,
|
|
208
|
-
createDir,
|
|
209
|
-
renameDir,
|
|
210
|
-
rimrafDir,
|
|
211
|
-
rimrafDirs,
|
|
212
|
-
checkIfFileExists,
|
|
213
|
-
readFile,
|
|
214
|
-
writeFile,
|
|
215
|
-
touchFile,
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
exports.default = { use, default: fs_extra_1.default, mock: mock_1.default };
|
|
219
|
-
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAA+B;AAC/B,gDAAwB;AAExB,oDAA4B;AAE5B,SAAS,GAAG,CAAC,SAAc,EAAE,SAAoB;IAC/C,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;IAE7J,IAAI,QAAQ,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,EAAE;QACrD,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE;YAC5B,gBAAgB,CAAC,IAAI,CAAC,CAAC;SACxB;KACF;IAED,SAAS,gBAAgB,CAAC,QAAgB;QACxC,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;QAChD,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,QAAQ,CAAC,OAAO,CAAC,CAAC;SACnB;IACH,CAAC;IAED,SAAS,QAAQ,CAAC,QAAc;QAC9B,OAAO;YACL,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,YAAY,CAAC,eAAe,CAAC,QA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