@visulima/fs 1.9.0 → 1.10.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## @visulima/fs [1.10.0](https://github.com/visulima/visulima/compare/@visulima/fs@1.9.0...@visulima/fs@1.10.0) (2024-03-19)
2
+
3
+
4
+ ### Features
5
+
6
+ * **fs:** added remove a wrapper around rm and unlink ([#354](https://github.com/visulima/visulima/issues/354)) ([ea30c3e](https://github.com/visulima/visulima/commit/ea30c3e3efd75e2bf07ca81af701543e087aff25))
7
+
1
8
  ## @visulima/fs [1.9.0](https://github.com/visulima/visulima/compare/@visulima/fs@1.8.0...@visulima/fs@1.9.0) (2024-03-19)
2
9
 
3
10
 
package/dist/index.cjs CHANGED
@@ -10,47 +10,49 @@ var process$1 = require('process');
10
10
  var zlib = require('zlib');
11
11
  var yaml = require('yaml');
12
12
 
13
- var q=t=>{if(!t||!(t instanceof URL)&&typeof t!="string")throw new TypeError("Path must be a non-empty string or URL.")},y=q;var Q=t=>{let e=t.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${e}$`)},h=Q;var Z=(t,e,r,o)=>e&&!e.some(n=>t.endsWith(n))||r&&!r.some(n=>n.test(t))?!1:!(o&&o.some(n=>n.test(t))),g=Z;var at=async t=>{let e=path.normalize(t),r=path.basename(e),o=await promises.stat(e);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:e}};async function*F(t,{extensions:e,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a,maxDepth:c=Number.POSITIVE_INFINITY,skip:d}={}){if(y(t),c<0)return;let f=a?a.map(i=>typeof i=="string"?h(i):i):void 0,m=d?d.map(i=>typeof i=="string"?h(i):i):void 0;if(t=path.resolve(chunkQHWRBSYR_cjs.a(t)),o&&g(t,e,f,m)&&(yield await at(t)),!(c<1||!g(t,void 0,void 0,m)))try{for await(let i of await promises.readdir(t,{withFileTypes:!0})){let u=path.join(t,i.name);if(i.isSymbolicLink())if(r)u=await promises.realpath(u);else if(s&&g(u,e,f,m))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:u};else continue;i.isSymbolicLink()||i.isDirectory()?yield*F(u,{extensions:e,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:s,match:f,maxDepth:c-1,skip:m}):i.isFile()&&n&&g(u,e,f,m)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:u});}}catch(i){throw i instanceof chunkKXYI7M76_cjs.a?i:new chunkKXYI7M76_cjs.a(i,t)}}var ft=async(t,e={})=>{let r={extensions:["js","mjs","cjs","ts"],...e},o=[];for await(let n of F(t,r))o.push(n.path);return o},ct=ft;var wt=t=>{let e=path.normalize(t),r=path.basename(e),o=fs.statSync(e);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:e}};function*x(t,{extensions:e,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a,maxDepth:c=Number.POSITIVE_INFINITY,skip:d}={}){if(y(t),c<0)return;let f=a?a.map(i=>typeof i=="string"?h(i):i):void 0,m=d?d.map(i=>typeof i=="string"?h(i):i):void 0;if(t=path.resolve(chunkQHWRBSYR_cjs.a(t)),o&&g(t,e,f,m)&&(yield wt(t)),!(c<1||!g(t,void 0,void 0,m)))try{for(let i of fs.readdirSync(t,{withFileTypes:!0})){let u=path.join(t,i.name);if(i.isSymbolicLink())if(r)u=fs.realpathSync(u);else if(s&&g(u,e,f,m))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:u};else continue;i.isSymbolicLink()||i.isDirectory()?yield*x(u,{extensions:e,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:s,match:f,maxDepth:c-1,skip:m}):i.isFile()&&n&&g(u,e,f,m)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:u});}}catch(i){throw i instanceof chunkKXYI7M76_cjs.a?i:new chunkKXYI7M76_cjs.a(i,t)}}var Ot=(t,e={})=>{let r={extensions:["js","mjs","cjs","ts"],...e},o=[];for(let n of x(t,r))o.push(n.path);return o},Rt=Ot;var R=0,P=4,St=2,ht=1,k=Symbol("findUpStop");var Tt=async(t,e)=>{if(y(t),!fs.existsSync(t)){await promises.mkdir(t,{recursive:!0});return}for await(let r of await promises.readdir(t))await promises.rm(path.join(chunkQHWRBSYR_cjs.a(t),r),{...e,force:!0,recursive:!0});},Et=Tt;var Jt=(t,e)=>{if(y(t),!fs.existsSync(t)){fs.mkdirSync(t,{recursive:!0});return}for(let r of fs.readdirSync(t))fs.rmSync(path.join(chunkQHWRBSYR_cjs.a(t),r),{...e,force:!0,recursive:!0});},Yt=Jt;var $=/\r?\n/g,_=`
13
+ var q=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},d=q;var Q=e=>{let t=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${t}$`)},b=Q;var Z=(e,t,r,o)=>t&&!t.some(n=>e.endsWith(n))||r&&!r.some(n=>n.test(e))?!1:!(o&&o.some(n=>n.test(e))),g=Z;var ae=async e=>{let t=path.normalize(e),r=path.basename(t),o=await promises.stat(t);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:t}};async function*F(e,{extensions:t,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a,maxDepth:c=Number.POSITIVE_INFINITY,skip:y}={}){if(d(e),c<0)return;let f=a?a.map(i=>typeof i=="string"?b(i):i):void 0,p=y?y.map(i=>typeof i=="string"?b(i):i):void 0;if(e=path.resolve(chunkQHWRBSYR_cjs.a(e)),o&&g(e,t,f,p)&&(yield await ae(e)),!(c<1||!g(e,void 0,void 0,p)))try{for await(let i of await promises.readdir(e,{withFileTypes:!0})){let u=path.join(e,i.name);if(i.isSymbolicLink())if(r)u=await promises.realpath(u);else if(s&&g(u,t,f,p))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:u};else continue;i.isSymbolicLink()||i.isDirectory()?yield*F(u,{extensions:t,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:s,match:f,maxDepth:c-1,skip:p}):i.isFile()&&n&&g(u,t,f,p)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:u});}}catch(i){throw i instanceof chunkKXYI7M76_cjs.a?i:new chunkKXYI7M76_cjs.a(i,e)}}var fe=async(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},o=[];for await(let n of F(e,r))o.push(n.path);return o},ce=fe;var we=e=>{let t=path.normalize(e),r=path.basename(t),o=fs.statSync(t);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:t}};function*x(e,{extensions:t,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a,maxDepth:c=Number.POSITIVE_INFINITY,skip:y}={}){if(d(e),c<0)return;let f=a?a.map(i=>typeof i=="string"?b(i):i):void 0,p=y?y.map(i=>typeof i=="string"?b(i):i):void 0;if(e=path.resolve(chunkQHWRBSYR_cjs.a(e)),o&&g(e,t,f,p)&&(yield we(e)),!(c<1||!g(e,void 0,void 0,p)))try{for(let i of fs.readdirSync(e,{withFileTypes:!0})){let u=path.join(e,i.name);if(i.isSymbolicLink())if(r)u=fs.realpathSync(u);else if(s&&g(u,t,f,p))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:u};else continue;i.isSymbolicLink()||i.isDirectory()?yield*x(u,{extensions:t,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:s,match:f,maxDepth:c-1,skip:p}):i.isFile()&&n&&g(u,t,f,p)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:u});}}catch(i){throw i instanceof chunkKXYI7M76_cjs.a?i:new chunkKXYI7M76_cjs.a(i,e)}}var Oe=(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},o=[];for(let n of x(e,r))o.push(n.path);return o},Re=Oe;var R=0,P=4,Se=2,be=1,k=Symbol("findUpStop");var De=async(e,t)=>{if(d(e),!fs.existsSync(e)){await promises.mkdir(e,{recursive:!0});return}for await(let r of await promises.readdir(e))await promises.rm(path.join(chunkQHWRBSYR_cjs.a(e),r),{...t,force:!0,recursive:!0});},ve=De;var Je=(e,t)=>{if(d(e),!fs.existsSync(e)){fs.mkdirSync(e,{recursive:!0});return}for(let r of fs.readdirSync(e))fs.rmSync(path.join(chunkQHWRBSYR_cjs.a(e),r),{...t,force:!0,recursive:!0});},Ye=Je;var $=/\r?\n/g,_=`
14
14
  `,Y=`\r
15
- `,It=process$1.platform==="win32"?Y:_,_t=t=>{let e=t.match($);if(!e||e.length===0)return null;let r=e.filter(n=>n===Y).length,o=e.length-r;return r>o?Y:_},Nt=(t,e)=>t.replaceAll($,e);var Kt=async(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=e.cwd?chunkQHWRBSYR_cjs.a(e.cwd):process.cwd();y(r);let o=path.resolve(r),{root:n}=path.parse(o),s=chunkQHWRBSYR_cjs.a(e.stopAt??n);y(s);let a=path.resolve(o,s),c=e.type??"file",d=async function(f){return typeof t=="function"?[await t(f)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};for(;o&&o!==a&&o!==n;){for await(let f of await d(o)){if(f===k)return;if(f===void 0)continue;let m=path.isAbsolute(f)?f:path.resolve(o,f);try{let i=await promises.stat(m);if(c==="file"&&i.isFile()||c==="directory"&&i.isDirectory())return m}catch{}}o=path.dirname(o);}},Mt=Kt;var Gt=(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=e.cwd?chunkQHWRBSYR_cjs.a(e.cwd):process.cwd();y(r);let o=path.resolve(r),{root:n}=path.parse(o),s=chunkQHWRBSYR_cjs.a(e.stopAt??n);y(s);let a=path.resolve(o,s),c=e.type??"file",d=function(f){return typeof t=="function"?[t(f)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};for(;o&&o!==a&&o!==n;){for(let f of d(o)){if(f===k)return;if(f===void 0)continue;let m=path.isAbsolute(f)?f:path.resolve(o,f);try{let i=fs.statSync(m);if(c==="file"&&i.isFile()||c==="directory"&&i.isDirectory())return m}catch{}}o=path.dirname(o);}},qt=Gt;async function Zt(t,e=0){y(t),t=chunkQHWRBSYR_cjs.a(t);try{return await promises.access(t,e),!0}catch{return !1}}var w=Zt;function ee(t,e=0){y(t),t=chunkQHWRBSYR_cjs.a(t);try{return fs.accessSync(t,e),!0}catch{return !1}}var O=ee;var ne={brotli:zlib.brotliDecompress,gzip:zlib.unzip,none:(t,e)=>{e(null,t);}},se=async(t,e)=>{if(y(t),t=chunkQHWRBSYR_cjs.a(t),!await w(t))throw new chunkKXYI7M76_cjs.b(`unable to read the non-accessible file: ${t}`);if(!await w(t,4))throw new Error(`Unable to read the non-readable file: ${t}`);let{buffer:r,compression:o,encoding:n,flag:s}=e??{};return await promises.readFile(t,s?{encoding:n,flag:s}:{encoding:n}).then(async a=>await new Promise((c,d)=>{ne[o??"none"](a,(f,m)=>{f?d(f):c(r?m:m.toString());});})).catch(a=>{throw a})},T=se;var me={brotli:zlib.brotliDecompressSync,gzip:zlib.unzipSync,none:t=>t},pe=(t,e)=>{if(y(t),t=chunkQHWRBSYR_cjs.a(t),!O(t))throw new chunkKXYI7M76_cjs.b(`unable to read the non-accessible file: ${t}`);if(!O(t,4))throw new chunkKXYI7M76_cjs.b(`invalid access to read file at: ${t}`);let{buffer:r,compression:o,encoding:n,flag:s}=e??{},a=fs.readFileSync(t,s?{encoding:n,flag:s}:{encoding:n}),c=me[o??"none"](a);return r?c:c.toString()},E=pe;async function le(t,e,r){typeof e=="object"&&(r=e,e=void 0);let o=await T(t,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(o),{beforeParse:s,color:a}=r??{};return typeof s=="function"&&(n=s(n)),chunkQHWRBSYR_cjs.b(n,e,chunkQHWRBSYR_cjs.a(t),{color:a})}var de=le;function ye(t,e,r){typeof e=="object"&&(r=e,e=void 0);let o=E(t,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(o),{beforeParse:s,color:a}=r??{};return typeof s=="function"&&(n=s(n)),chunkQHWRBSYR_cjs.b(n,e,chunkQHWRBSYR_cjs.a(t),{color:a})}var ue=ye;async function ge(t,e,r){let{buffer:o,compression:n,encoding:s="utf8",flag:a,...c}=r??{},d=await T(t,{buffer:o,compression:n,encoding:s,flag:a});return typeof e=="function"?yaml.parse(d,e,c):yaml.parse(d,c)}var we=ge;function Oe(t,e,r){let{buffer:o,compression:n,encoding:s="utf8",flag:a,...c}=r??{},d=E(t,{buffer:o,compression:n,encoding:s,flag:a});return typeof e=="function"?yaml.parse(d,e,c):yaml.parse(d,c)}var Re=Oe;var Se=t=>{if(typeof t!="string"&&!(t instanceof ArrayBuffer)&&!ArrayBuffer.isView(t))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},W=Se;var he=new TextEncoder,be=t=>{if(t instanceof Uint8Array)return t;if(typeof t=="string")return he.encode(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t)){let e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return new Uint8Array(e)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},I=be;var Ue=async(t,e,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},y(t),W(e),t=chunkQHWRBSYR_cjs.a(t);try{let o=await w(t,0);if(!o&&r.recursive){let a=path.dirname(t);await w(a,0)||await promises.mkdir(a,{recursive:!0});}let n;await promises.writeFile(`${t}.tmp`,I(e),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(n=await promises.stat(t),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),await promises.rename(t,`${t}.bak`));let s=`${t}.tmp`;if(r.chown)try{await promises.chown(s,r.chown.uid,r.chown.gid);}catch{}await promises.chmod(s,n&&!r.mode?n.mode:r.mode??438),await promises.rename(s,t);}catch(o){throw new Error(`Failed to write file at: ${t} - ${o.message}`,{cause:o})}finally{await w(`${t}.tmp`)&&await promises.unlink(`${t}.tmp`);}},L=Ue;var _e=(t,e,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},y(t),W(e),t=chunkQHWRBSYR_cjs.a(t);try{let o=O(t,0);if(!o&&r.recursive){let a=path.dirname(t);O(a,0)||fs.mkdirSync(a,{recursive:!0});}let n;fs.writeFileSync(`${t}.tmp`,I(e),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(n=fs.statSync(t),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),fs.renameSync(t,`${t}.bak`));let s=`${t}.tmp`;if(r.chown)try{fs.chownSync(s,r.chown.uid,r.chown.gid);}catch{}fs.chmodSync(s,n&&!r.mode?n.mode:r.mode??438),fs.renameSync(s,t);}catch(o){throw new Error(`Failed to write file at: ${t} - ${o.message}`,{cause:o})}finally{O(`${t}.tmp`)&&fs.unlinkSync(`${t}.tmp`);}},U=_e;var Ne=/^(?:( )+|\t+)/,D="space",j="tab";function B(t,e){let r=new Map,o=0,n,s;for(let a of t.split(/\n/g)){if(!a)continue;let c,d,f,m,i,u=a.match(Ne);if(u===null)o=0,n="";else {if(c=u[0].length,d=u[1]?D:j,e&&d===D&&c===1)continue;d!==n&&(o=0),n=d,f=1,m=0;let A=c-o;if(o=c,A===0)f=0,m=1;else {let G=A>0?A:-A;s=Ve(d,G);}i=r.get(s),i=i===void 0?[1,0]:[i[0]+f,i[1]+m],r.set(s,i);}}return r}function Ve(t,e){return (t===D?"s":"t")+String(e)}function $e(t){let r=t[0]==="s"?D:j,o=Number(t.slice(1));return {type:r,amount:o}}function Ce(t){let e,r=0,o=0;for(let[n,[s,a]]of t)(s>r||s===r&&a>o)&&(r=s,o=a,e=n);return e}function ze(t,e){return (t===D?" ":" ").repeat(e)}function v(t){if(typeof t!="string")throw new TypeError("Expected a string");let e=B(t,!0);e.size===0&&(e=B(t,!1));let r=Ce(e),o,n=0,s="";return r!==void 0&&({type:o,amount:n}=$e(r),s=ze(o,n)),{amount:n,type:o,indent:s}}var Me=async(t,e,r={})=>{let{detectIndent:o,indent:n,replacer:s,stringify:a=JSON.stringify,...c}={indent:" ",...r},d=n,f=`
16
- `;if(await w(t,4))try{let i=await promises.readFile(t,"utf8");if(o){let{indent:u}=v(i);d=u;}f=i.endsWith(`
15
+ `,Ie=process$1.platform==="win32"?Y:_,_e=e=>{let t=e.match($);if(!t||t.length===0)return null;let r=t.filter(n=>n===Y).length,o=t.length-r;return r>o?Y:_},Ne=(e,t)=>e.replaceAll($,t);var Ke=async(e,t={})=>{if(typeof e!="string"&&!Array.isArray(e)&&typeof e!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=t.cwd?chunkQHWRBSYR_cjs.a(t.cwd):process.cwd();d(r);let o=path.resolve(r),{root:n}=path.parse(o),s=chunkQHWRBSYR_cjs.a(t.stopAt??n);d(s);let a=path.resolve(o,s),c=t.type??"file",y=async function(f){return typeof e=="function"?[await e(f)]:typeof e=="string"?[e]:Array.isArray(e)?e:[e]};for(;o&&o!==a&&o!==n;){for await(let f of await y(o)){if(f===k)return;if(f===void 0)continue;let p=path.isAbsolute(f)?f:path.resolve(o,f);try{let i=await promises.stat(p);if(c==="file"&&i.isFile()||c==="directory"&&i.isDirectory())return p}catch{}}o=path.dirname(o);}},Me=Ke;var Ge=(e,t={})=>{if(typeof e!="string"&&!Array.isArray(e)&&typeof e!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=t.cwd?chunkQHWRBSYR_cjs.a(t.cwd):process.cwd();d(r);let o=path.resolve(r),{root:n}=path.parse(o),s=chunkQHWRBSYR_cjs.a(t.stopAt??n);d(s);let a=path.resolve(o,s),c=t.type??"file",y=function(f){return typeof e=="function"?[e(f)]:typeof e=="string"?[e]:Array.isArray(e)?e:[e]};for(;o&&o!==a&&o!==n;){for(let f of y(o)){if(f===k)return;if(f===void 0)continue;let p=path.isAbsolute(f)?f:path.resolve(o,f);try{let i=fs.statSync(p);if(c==="file"&&i.isFile()||c==="directory"&&i.isDirectory())return p}catch{}}o=path.dirname(o);}},qe=Ge;async function Ze(e,t=0){d(e),e=chunkQHWRBSYR_cjs.a(e);try{return await promises.access(e,t),!0}catch{return !1}}var w=Ze;function tt(e,t=0){d(e),e=chunkQHWRBSYR_cjs.a(e);try{return fs.accessSync(e,t),!0}catch{return !1}}var O=tt;var nt={brotli:zlib.brotliDecompress,gzip:zlib.unzip,none:(e,t)=>{t(null,e);}},st=async(e,t)=>{if(d(e),e=chunkQHWRBSYR_cjs.a(e),!await w(e))throw new chunkKXYI7M76_cjs.b(`unable to read the non-accessible file: ${e}`);if(!await w(e,4))throw new Error(`Unable to read the non-readable file: ${e}`);let{buffer:r,compression:o,encoding:n,flag:s}=t??{};return await promises.readFile(e,s?{encoding:n,flag:s}:{encoding:n}).then(async a=>await new Promise((c,y)=>{nt[o??"none"](a,(f,p)=>{f?y(f):c(r?p:p.toString());});})).catch(a=>{throw a})},D=st;var mt={brotli:zlib.brotliDecompressSync,gzip:zlib.unzipSync,none:e=>e},pt=(e,t)=>{if(d(e),e=chunkQHWRBSYR_cjs.a(e),!O(e))throw new chunkKXYI7M76_cjs.b(`unable to read the non-accessible file: ${e}`);if(!O(e,4))throw new chunkKXYI7M76_cjs.b(`invalid access to read file at: ${e}`);let{buffer:r,compression:o,encoding:n,flag:s}=t??{},a=fs.readFileSync(e,s?{encoding:n,flag:s}:{encoding:n}),c=mt[o??"none"](a);return r?c:c.toString()},v=pt;async function lt(e,t,r){typeof t=="object"&&(r=t,t=void 0);let o=await D(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(o),{beforeParse:s,color:a}=r??{};return typeof s=="function"&&(n=s(n)),chunkQHWRBSYR_cjs.b(n,t,chunkQHWRBSYR_cjs.a(e),{color:a})}var dt=lt;function yt(e,t,r){typeof t=="object"&&(r=t,t=void 0);let o=v(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(o),{beforeParse:s,color:a}=r??{};return typeof s=="function"&&(n=s(n)),chunkQHWRBSYR_cjs.b(n,t,chunkQHWRBSYR_cjs.a(e),{color:a})}var ut=yt;async function gt(e,t,r){let{buffer:o,compression:n,encoding:s="utf8",flag:a,...c}=r??{},y=await D(e,{buffer:o,compression:n,encoding:s,flag:a});return typeof t=="function"?yaml.parse(y,t,c):yaml.parse(y,c)}var wt=gt;function Ot(e,t,r){let{buffer:o,compression:n,encoding:s="utf8",flag:a,...c}=r??{},y=v(e,{buffer:o,compression:n,encoding:s,flag:a});return typeof t=="function"?yaml.parse(y,t,c):yaml.parse(y,c)}var Rt=Ot;var ht=async(e,t={})=>{d(e);try{await promises.unlink(e);}catch{}try{await promises.rm(e,{force:!0,maxRetries:t?.maxRetries,recursive:!0,retryDelay:t?.retryDelay});}catch{}},Ft=ht;var kt=(e,t={})=>{d(e);try{fs.unlinkSync(e);}catch{}try{fs.rmSync(e,{force:!0,maxRetries:t?.maxRetries,recursive:!0,retryDelay:t?.retryDelay});}catch{}},Dt=kt;var vt=e=>{if(typeof e!="string"&&!(e instanceof ArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},W=vt;var Tt=new TextEncoder,Et=e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return Tt.encode(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e)){let t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},I=Et;var _t=async(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},d(e),W(t),e=chunkQHWRBSYR_cjs.a(e);try{let o=await w(e,0);if(!o&&r.recursive){let a=path.dirname(e);await w(a,0)||await promises.mkdir(a,{recursive:!0});}let n;await promises.writeFile(`${e}.tmp`,I(t),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(n=await promises.stat(e),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),await promises.rename(e,`${e}.bak`));let s=`${e}.tmp`;if(r.chown)try{await promises.chown(s,r.chown.uid,r.chown.gid);}catch{}await promises.chmod(s,n&&!r.mode?n.mode:r.mode??438),await promises.rename(s,e);}catch(o){throw new Error(`Failed to write file at: ${e} - ${o.message}`,{cause:o})}finally{await w(`${e}.tmp`)&&await promises.unlink(`${e}.tmp`);}},T=_t;var Bt=(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},d(e),W(t),e=chunkQHWRBSYR_cjs.a(e);try{let o=O(e,0);if(!o&&r.recursive){let a=path.dirname(e);O(a,0)||fs.mkdirSync(a,{recursive:!0});}let n;fs.writeFileSync(`${e}.tmp`,I(t),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(n=fs.statSync(e),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),fs.renameSync(e,`${e}.bak`));let s=`${e}.tmp`;if(r.chown)try{fs.chownSync(s,r.chown.uid,r.chown.gid);}catch{}fs.chmodSync(s,n&&!r.mode?n.mode:r.mode??438),fs.renameSync(s,e);}catch(o){throw new Error(`Failed to write file at: ${e} - ${o.message}`,{cause:o})}finally{O(`${e}.tmp`)&&fs.unlinkSync(`${e}.tmp`);}},E=Bt;var jt=/^(?:( )+|\t+)/,L="space",j="tab";function B(e,t){let r=new Map,o=0,n,s;for(let a of e.split(/\n/g)){if(!a)continue;let c,y,f,p,i,u=a.match(jt);if(u===null)o=0,n="";else {if(c=u[0].length,y=u[1]?L:j,t&&y===L&&c===1)continue;y!==n&&(o=0),n=y,f=1,p=0;let A=c-o;if(o=c,A===0)f=0,p=1;else {let G=A>0?A:-A;s=Xt(y,G);}i=r.get(s),i=i===void 0?[1,0]:[i[0]+f,i[1]+p],r.set(s,i);}}return r}function Xt(e,t){return (e===L?"s":"t")+String(t)}function Ht(e){let r=e[0]==="s"?L:j,o=Number(e.slice(1));return {type:r,amount:o}}function Gt(e){let t,r=0,o=0;for(let[n,[s,a]]of e)(s>r||s===r&&a>o)&&(r=s,o=a,t=n);return t}function qt(e,t){return (e===L?" ":" ").repeat(t)}function U(e){if(typeof e!="string")throw new TypeError("Expected a string");let t=B(e,!0);t.size===0&&(t=B(e,!1));let r=Gt(t),o,n=0,s="";return r!==void 0&&({type:o,amount:n}=Ht(r),s=qt(o,n)),{amount:n,type:o,indent:s}}var Zt=async(e,t,r={})=>{let{detectIndent:o,indent:n,replacer:s,stringify:a=JSON.stringify,...c}={indent:" ",...r},y=n,f=`
16
+ `;if(await w(e,4))try{let i=await promises.readFile(e,"utf8");if(o){let{indent:u}=U(i);y=u;}f=i.endsWith(`
17
17
  `)?`
18
- `:"";}catch(i){if(i.code!=="ENOENT")throw i}let m=a(e,s,d);await L(t,`${m}${f}`,c);},Be=Me;var Xe=(t,e,r={})=>{let{detectIndent:o,indent:n,replacer:s,stringify:a=JSON.stringify,...c}={indent:" ",...r},d=n,f=`
19
- `;if(O(t,4))try{let i=fs.readFileSync(t,"utf8");if(o){let{indent:u}=v(i);d=u;}f=i.endsWith(`
18
+ `:"";}catch(i){if(i.code!=="ENOENT")throw i}let p=a(t,s,y);await T(e,`${p}${f}`,c);},er=Zt;var rr=(e,t,r={})=>{let{detectIndent:o,indent:n,replacer:s,stringify:a=JSON.stringify,...c}={indent:" ",...r},y=n,f=`
19
+ `;if(O(e,4))try{let i=fs.readFileSync(e,"utf8");if(o){let{indent:u}=U(i);y=u;}f=i.endsWith(`
20
20
  `)?`
21
- `:"";}catch(i){if(i.code!=="ENOENT")throw i}let m=a(e,s,d);U(t,`${m}${f}`,c);},He=Xe;async function Ge(t,e,r,o){let n=typeof r=="function"||Array.isArray(r)?yaml.stringify(e,r,o):yaml.stringify(e,r);await L(t,n);}var qe=Ge;function Qe(t,e,r,o){let n=typeof r=="function"||Array.isArray(r)?yaml.stringify(e,r,o):yaml.stringify(e,r);U(t,n);}var Ze=Qe;
21
+ `:"";}catch(i){if(i.code!=="ENOENT")throw i}let p=a(t,s,y);E(e,`${p}${f}`,c);},or=rr;async function ir(e,t,r,o){let n=typeof r=="function"||Array.isArray(r)?yaml.stringify(t,r,o):yaml.stringify(t,r);await T(e,n);}var nr=ir;function sr(e,t,r,o){let n=typeof r=="function"||Array.isArray(r)?yaml.stringify(t,r,o):yaml.stringify(t,r);E(e,n);}var ar=sr;
22
22
 
23
23
  exports.CRLF = Y;
24
- exports.EOL = It;
24
+ exports.EOL = Ie;
25
25
  exports.FIND_UP_STOP = k;
26
26
  exports.F_OK = R;
27
27
  exports.LF = _;
28
28
  exports.R_OK = P;
29
- exports.W_OK = St;
30
- exports.X_OK = ht;
31
- exports.collect = ct;
32
- exports.collectSync = Rt;
33
- exports.detect = _t;
34
- exports.emptyDir = Et;
35
- exports.emptyDirSync = Yt;
36
- exports.findUp = Mt;
37
- exports.findUpSync = qt;
38
- exports.format = Nt;
29
+ exports.W_OK = Se;
30
+ exports.X_OK = be;
31
+ exports.collect = ce;
32
+ exports.collectSync = Re;
33
+ exports.detect = _e;
34
+ exports.emptyDir = ve;
35
+ exports.emptyDirSync = Ye;
36
+ exports.findUp = Me;
37
+ exports.findUpSync = qe;
38
+ exports.format = Ne;
39
39
  exports.isAccessible = w;
40
40
  exports.isAccessibleSync = O;
41
- exports.readFile = T;
42
- exports.readFileSync = E;
43
- exports.readJson = de;
44
- exports.readJsonSync = ue;
45
- exports.readYaml = we;
46
- exports.readYamlSync = Re;
41
+ exports.readFile = D;
42
+ exports.readFileSync = v;
43
+ exports.readJson = dt;
44
+ exports.readJsonSync = ut;
45
+ exports.readYaml = wt;
46
+ exports.readYamlSync = Rt;
47
+ exports.remove = Ft;
48
+ exports.removeSync = Dt;
47
49
  exports.walk = F;
48
50
  exports.walkSync = x;
49
- exports.writeFile = L;
50
- exports.writeFileSync = U;
51
- exports.writeJson = Be;
52
- exports.writeJsonSync = He;
53
- exports.writeYaml = qe;
54
- exports.writeYamlSync = Ze;
51
+ exports.writeFile = T;
52
+ exports.writeFileSync = E;
53
+ exports.writeJson = er;
54
+ exports.writeJsonSync = or;
55
+ exports.writeYaml = nr;
56
+ exports.writeYamlSync = ar;
55
57
  //# sourceMappingURL=out.js.map
56
58
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/walk.ts","../src/utils/assert-valid-file-or-directory-path.ts","../src/utils/glob-to-regex.ts","../src/utils/walk-include.ts","../src/collect.ts","../src/walk-sync.ts","../src/collect-sync.ts","../src/constants.ts","../src/empty-dir.ts","../src/empty-dir-sync.ts","../src/eol.ts","../src/find-up.ts","../src/find-up-sync.ts","../src/is-accessible.ts","../src/is-accessible-sync.ts","../src/read-file.ts","../src/read-file-sync.ts","../src/read-json.ts","../src/read-json-sync.ts","../src/read-yaml.ts","../src/read-yaml-sync.ts","../src/write-file.ts","../src/utils/assert-valid-file-contents.ts","../src/utils/to-uint-8-array.ts","../src/write-file-sync.ts","../src/write-json.ts","../../../node_modules/.pnpm/detect-indent@7.0.1/node_modules/detect-indent/index.js","../src/write-json-sync.ts","../src/write-yaml.ts","../src/write-yaml-sync.ts"],"names":["readdir","realpath","stat","basename","join","normalize","resolve","assertValidFileOrDirectoryPath","fileOrDirectoryPath","assert_valid_file_or_directory_path_default","globToRegExp","glob","reString","glob_to_regex_default","walkInclude","path","extensions","match","skip","extension","pattern","walk_include_default","_createWalkEntry","normalizePath","name","info","walk","directory","followSymlinks","includeDirectories","includeFiles","includeSymlinks","maxDepth","mappedMatch","mappedSkip","to_path_default","entry","error","walk_error_default","collect","options","config","entries","collect_default","readdirSync","realpathSync","statSync","walkSync","collectSync","collect_sync_default","F_OK","R_OK","W_OK","X_OK","FIND_UP_STOP","existsSync","mkdir","rm","emptyDir","dir","item","empty_dir_default","mkdirSync","rmSync","empty_dir_sync_default","platform","regDetect","LF","CRLF","EOL","detect","content","d","crlf","newline","lf","format","eol","dirname","isAbsolute","parse","findUp","cwd","root","stopPath","stopAt","type","getMatchers","currentDirectory","fileName","filePath","stats","find_up_default","findUpSync","find_up_sync_default","access","isAccessible","mode","is_accessible_default","accessSync","isAccessibleSync","is_accessible_sync_default","nodeReadFile","brotliDecompress","unzip","decompressionMethods","buffer","callback","readFile","permission_error_default","compression","encoding","flag","reject","result","read_file_default","nodeReadFileSync","brotliDecompressSync","unzipSync","readFileSync","decompressed","read_file_sync_default","readJson","reviver","data","beforeParse","color","parse_json_default","read_json_default","readJsonSync","read_json_sync_default","readYaml","parseOptions","read_yaml_default","readYamlSync","read_yaml_sync_default","chmod","chown","rename","nodeStat","unlink","nodeWriteFile","assertValidFileContents","contents","assert_valid_file_contents_default","encoder","toUint8Array","bytes","to_uint_8_array_default","writeFile","pathExists","temporaryPath","write_file_default","chmodSync","chownSync","renameSync","unlinkSync","nodeWriteFileSync","writeFileSync","write_file_sync_default","INDENT_REGEX","INDENT_TYPE_SPACE","INDENT_TYPE_TAB","makeIndentsMap","string","ignoreSingleSpaces","indents","previousSize","previousIndentType","key","line","indent","indentType","use","weight","matches","indentDifference","absoluteIndentDifference","encodeIndentsKey","indentAmount","decodeIndentsKey","indentsKey","amount","getMostUsedKey","maxUsed","maxWeight","usedCount","makeIndentString","detectIndent","keyOfMostUsedIndent","writeJson","indentOption","replacer","stringify","writeOptions","trailingNewline","file","dIndent","json","write_json_default","writeJsonSync","write_json_sync_default","writeYaml","write_yaml_default","writeYamlSync","write_yaml_sync_default"],"mappings":"wHAMA,OAAS,WAAAA,GAAS,YAAAC,GAAU,QAAAC,OAAY,cACxC,OAAS,YAAAC,GAAU,QAAAC,GAAM,aAAAC,GAAW,WAAAC,OAAe,OCNnD,IAAMC,EAAkCC,GAAmC,CACvE,GAAI,CAACA,GAAwB,EAAEA,aAA+B,MAAQ,OAAOA,GAAwB,SACjG,MAAM,IAAI,UAAU,yCAAyC,CAErE,EAEOC,EAAQF,ECPf,IAAMG,EAAgBC,GAAyB,CAC3C,IAAMC,EAAWD,EAEZ,QAAQ,QAAS,UAAU,EAE3B,QAAQ,QAAS,MAAM,EAEvB,QAAQ,mBAAoB,SAAS,EAErC,QAAQ,MAAO,MAAM,EAErB,QAAQ,YAAa,KAAK,EAE1B,QAAQ,MAAO,GAAG,EAElB,QAAQ,MAAO,GAAG,EAElB,QAAQ,KAAM,GAAG,EAEjB,QAAQ,cAAe,OAAO,EAGnC,OAAO,IAAI,OAAO,IAAIC,CAAQ,GAAG,CACrC,EAEOC,EAAQH,ECzBf,IAAMI,EAAc,CAACC,EAAcC,EAAuBC,EAAkBC,IACpEF,GAAc,CAACA,EAAW,KAAMG,GAAuBJ,EAAK,SAASI,CAAS,CAAC,GAI/EF,GAAS,CAACA,EAAM,KAAMG,GAAqBA,EAAQ,KAAKL,CAAI,CAAC,EACtD,GAGJ,EAAEG,GAAQA,EAAK,KAAME,GAAqBA,EAAQ,KAAKL,CAAI,CAAC,GAGhEM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;AAAA,CAAI,EAAI;AAAA,EAAO,EAEnD,OAAS/J,EAAY,CAEjB,GAAIA,EAAM,OAAS,SACf,MAAMA,CAEd,CAIJ,IAAMiK,EAAOL,EAAUrE,EAAMoE,EAAUrB,CAAM,EAE7CZ,EAAchJ,EAAM,GAAGuL,CAAI,GAAGH,CAAe,GAAID,CAAY,CACjE,EAEOO,GAAQD,GC3Cf,OAAS,aAAAP,MAAiB,OAuB1B,eAAeS,GACX3L,EAEA6G,EAEAoE,EAEAxJ,EACa,CAEb,IAAM+B,EAAU,OAAOyH,GAAa,YAAc,MAAM,QAAQA,CAAQ,EAAIC,EAAUrE,EAAMoE,EAAUxJ,CAAO,EAAIyJ,EAAUrE,EAAMoE,CAAwB,EAGzJ,MAAMxC,EAAUzI,EAAMwD,CAAO,CACjC,CAEA,IAAOoI,GAAQD,GCvCf,OAAS,aAAAT,MAAiB,OAuB1B,SAASW,GACL7L,EAEA6G,EAEAoE,EAEAxJ,EACI,CAEJ,IAAM+B,EAAU,OAAOyH,GAAa,YAAc,MAAM,QAAQA,CAAQ,EAAIC,EAAUrE,EAAMoE,EAAUxJ,CAAO,EAAIyJ,EAAUrE,EAAMoE,CAAwB,EAGzJjC,EAAchJ,EAAMwD,CAAO,CAC/B,CAEA,IAAOsI,GAAQD","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdir, realpath, stat } from \"node:fs/promises\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = async (path: string): Promise<WalkEntry> => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = await stat(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/**\n * Walks the file tree rooted at root, yielding each file or directory in the\n * tree filtered according to the given options.\n * Options:\n * - maxDepth?: number = Infinity;\n * - includeFiles?: boolean = true;\n * - includeDirs?: boolean = true;\n * - includeSymlinks?: boolean = true;\n * - followSymlinks?: boolean = false;\n * - extensions?: string[];\n * - match?: string | ReadonlyArray<string>;\n * - skip?: string | ReadonlyArray<string>;\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default async function* walk(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): AsyncIterableIterator<WalkEntry> {\n assertValidFileOrDirectoryPath(directory);\n\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield await _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,security/detect-non-literal-fs-filename,no-loops/no-loops\n for await (const entry of await readdir(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = await realpath(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walk(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileOrDirectoryPath = (fileOrDirectoryPath: any): void => {\n if (!fileOrDirectoryPath || (!(fileOrDirectoryPath instanceof URL) && typeof fileOrDirectoryPath !== \"string\")) {\n throw new TypeError(\"Path must be a non-empty string or URL.\");\n }\n};\n\nexport default assertValidFileOrDirectoryPath;\n","const globToRegExp = (glob: string): RegExp => {\n const reString = glob\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.\\*/g, \".([^/]*)\") // Replace .* with .([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\*\\*/g, \"(.*)\") // Replace ** with (.*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/(?<!\\.)\\*(?!\\*)/g, \"([^/]*)\") // Replace * (not preceded by . or followed by *) with ([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\?/g, \"[^/]\") // Replace ? with [^/]\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.(?!\\*)/g, \"\\\\.\") // Escape . that is not preceded by *\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\{/g, \"(\") // Replace { with (\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\}/g, \")\") // Replace } with )\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/,/g, \"|\") // Replace , with |\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\[!(.*?)\\]/g, \"[^$1]\"); // Replace [!number-number] with [^number-number]\n\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp,security/detect-non-literal-regexp\n return new RegExp(`^${reString}$`);\n};\n\nexport default globToRegExp;\n","const walkInclude = (path: string, extensions?: string[], match?: RegExp[], skip?: RegExp[]): boolean => {\n if (extensions && !extensions.some((extension): boolean => path.endsWith(extension))) {\n return false;\n }\n\n if (match && !match.some((pattern): boolean => pattern.test(path))) {\n return false;\n }\n\n return !(skip && skip.some((pattern): boolean => pattern.test(path)));\n};\n\nexport default walkInclude;\n","import type { WalkOptions } from \"./types\";\nimport walk from \"./walk\";\n\nconst collect = async (directory: string, options: WalkOptions = {}): Promise<string[]> => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for await (const entry of walk(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collect;\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n/** Create {@linkcode WalkEntry} for the `path` synchronously. */\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = (path: string): WalkEntry => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = statSync(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/** Same as {@linkcode walk} but uses synchronous ops */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default function* walkSync(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): IterableIterator<WalkEntry> {\n assertValidFileOrDirectoryPath(directory);\n\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops,security/detect-non-literal-fs-filename\n for (const entry of readdirSync(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = realpathSync(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walkSync(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","import type { WalkOptions } from \"./types\";\nimport walkSync from \"./walk-sync\";\n\nconst collectSync = (directory: string, options: WalkOptions = {}): string[] => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const entry of walkSync(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collectSync;\n","/** Is the path visible to the calling process? */\nexport const F_OK = 0; // constants?.F_OK\n\n/** Is the path readable to the calling process? */\nexport const R_OK = 4; // constants?.R_OK\n\n/** Is the path writable to the calling process? */\nexport const W_OK = 2; // constants?.W_OK\n\n/** Is the path executable to the calling process? */\nexport const X_OK = 1; // constants?.X_OK\n\nexport const FIND_UP_STOP = Symbol(\"findUpStop\");\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport { existsSync } from \"node:fs\";\nimport { mkdir, readdir, rm } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nimport type { EmptyDirOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/**\n * Ensures that a directory is empty.\n * Deletes directory contents if the directory is not empty.\n * If the directory does not exist, it is created.\n * The directory itself is not deleted.\n */\n// eslint-disable-next-line unicorn/prevent-abbreviations\nconst emptyDir = async (dir: URL | string, options?: EmptyDirOptions): Promise<void> => {\n assertValidFileOrDirectoryPath(dir);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(dir)) {\n // if not exist. then create it\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await mkdir(dir, { recursive: true });\n\n return;\n }\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax,security/detect-non-literal-fs-filename\n for await (const item of await readdir(dir)) {\n await rm(join(toPath(dir), item), { ...options, force: true, recursive: true });\n }\n}\n\nexport default emptyDir;\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport { existsSync, mkdirSync, readdirSync, rmSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nimport type { EmptyDirOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/**\n * Ensures that a directory is empty.\n * Deletes directory contents if the directory is not empty.\n * If the directory does not exist, it is created.\n * The directory itself is not deleted.\n */\n// eslint-disable-next-line unicorn/prevent-abbreviations\nconst emptyDir = (dir: URL | string, options?: EmptyDirOptions): void => {\n assertValidFileOrDirectoryPath(dir);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(dir)) {\n // if not exist. then create it\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(dir, { recursive: true });\n\n return;\n }\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax,security/detect-non-literal-fs-filename\n for (const item of readdirSync(dir)) {\n rmSync(join(toPath(dir), item), { ...options, force: true, recursive: true });\n }\n}\n\nexport default emptyDir;\n","import { platform } from \"node:process\";\n\nconst regDetect = /\\r?\\n/g;\n\n/** End-of-line character for POSIX platforms such as macOS and Linux. */\nexport const LF = \"\\n\" as const;\n\n/** End-of-line character for Windows platforms. */\nexport const CRLF = \"\\r\\n\" as const;\n\n/**\n * End-of-line character evaluated for the current platform.\n */\nexport const EOL: \"\\n\" | \"\\r\\n\" = platform === \"win32\" ? CRLF : LF;\n\n/**\n * Detect the EOL character for string input.\n * Returns null if no newline.\n */\nexport const detect = (content: string): typeof EOL | null => {\n const d = content.match(regDetect);\n\n if (!d || d.length === 0) {\n return null;\n }\n\n const crlf = d.filter((newline) => newline === CRLF).length;\n const lf = d.length - crlf;\n\n return crlf > lf ? CRLF : LF;\n};\n\n/**\n * Format the file to the targeted EOL.\n */\nexport const format = (content: string, eol: typeof EOL): string => content.replaceAll(regDetect, eol);\n","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, parse, resolve } from \"node:path\";\n\nimport { FIND_UP_STOP } from \"./constants\";\nimport type { FindUpOptions, Match } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: ReadonlyArray<string> | string[] | string | ((directory: string) => Match | Promise<Match>),\n options: FindUpOptions = {},\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): Promise<string | undefined> => {\n if (typeof name !== \"string\" && !Array.isArray(name) && typeof name !== \"function\") {\n throw new TypeError(\"The `name` argument must be of type `string` or `string[]`\");\n }\n\n const cwd = options.cwd ? toPath(options.cwd) : process.cwd();\n\n assertValidFileOrDirectoryPath(cwd);\n\n let directory = resolve(cwd);\n\n const { root } = parse(directory);\n const stopPath = toPath(options.stopAt ?? root);\n\n assertValidFileOrDirectoryPath(stopPath);\n\n const stopAt = resolve(directory, stopPath);\n const type = options.type ?? \"file\";\n\n const getMatchers = async function (currentDirectory: string): Promise<(string | typeof FIND_UP_STOP | undefined)[]> {\n if (typeof name === \"function\") {\n const match = await name(currentDirectory);\n\n return [match];\n }\n\n if (typeof name === \"string\") {\n return [name];\n }\n\n if (Array.isArray(name)) {\n return name as string[];\n }\n\n return [name];\n };\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n // eslint-disable-next-line no-await-in-loop,no-loops/no-loops,no-restricted-syntax\n for await (const fileName of await getMatchers(directory)) {\n if (fileName === FIND_UP_STOP) {\n return undefined;\n }\n\n if (fileName === undefined) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = await stat(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUp;\n","import { statSync } from \"node:fs\";\nimport { dirname, isAbsolute, parse, resolve } from \"node:path\";\n\nimport { FIND_UP_STOP } from \"./constants\";\nimport type { FindUpOptions, Match } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: ReadonlyArray<string> | string[] | string | ((directory: string) => Match),\n options: FindUpOptions = {},\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): string | undefined => {\n if (typeof name !== \"string\" && !Array.isArray(name) && typeof name !== \"function\") {\n throw new TypeError(\"The `name` argument must be of type `string` or `string[]`\");\n }\n\n const cwd = options.cwd ? toPath(options.cwd) : process.cwd();\n\n assertValidFileOrDirectoryPath(cwd);\n\n let directory = resolve(cwd);\n\n const { root } = parse(directory);\n const stopPath = toPath(options.stopAt ?? root);\n\n assertValidFileOrDirectoryPath(stopPath);\n\n const stopAt = resolve(directory, stopPath);\n const type = options.type ?? \"file\";\n\n const getMatchers = function (currentDirectory: string): (string | typeof FIND_UP_STOP | undefined)[] {\n if (typeof name === \"function\") {\n const match = name(currentDirectory);\n\n return [match];\n }\n\n if (typeof name === \"string\") {\n return [name];\n }\n\n if (Array.isArray(name)) {\n return name as string[];\n }\n\n return [name];\n };\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const fileName of getMatchers(directory)) {\n if (fileName === FIND_UP_STOP) {\n return undefined;\n }\n\n if (fileName === undefined) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = statSync(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUpSync;\n","import { access } from \"node:fs/promises\";\n\nimport { F_OK } from \"./constants\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/** Returns a Promise that resolves to a boolean indicating if the path is accessible or not. */\nasync function isAccessible(path: URL | string, mode?: number): Promise<boolean>;\n// eslint-disable-next-line func-style\nasync function isAccessible(path: URL | string, mode: number = F_OK): Promise<boolean> {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n await access(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessible;\n","import { accessSync } from \"node:fs\";\n\nimport { F_OK } from \"./constants\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/** Returns a boolean indicating if the path is accessible or not. */\nfunction isAccessibleSync(path: URL | string, mode?: number): boolean;\n// eslint-disable-next-line func-style\nfunction isAccessibleSync(path: URL | string, mode: number = F_OK): boolean {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n accessSync(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessibleSync;\n","import { readFile as nodeReadFile } from \"node:fs/promises\";\nimport { brotliDecompress, unzip } from \"node:zlib\";\n\nimport { R_OK } from \"./constants\";\nimport PermissionError from \"./error/permission-error\";\nimport isAccessible from \"./is-accessible\";\nimport type { ContentType, ReadFileOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst decompressionMethods = {\n brotli: brotliDecompress,\n gzip: unzip,\n none: (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => {\n callback(null, buffer);\n },\n} as const;\n\nconst readFile = async <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: URL | string,\n options?: O,\n): Promise<ContentType<O>> => {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n if (!(await isAccessible(path))) {\n throw new PermissionError(`unable to read the non-accessible file: ${path}`);\n }\n\n if (!(await isAccessible(path, R_OK))) {\n throw new Error(`Unable to read the non-readable file: ${path}`);\n }\n\n const { buffer, compression, encoding, flag } = options ?? {};\n\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n return await nodeReadFile(path, flag ? { encoding, flag } : { encoding })\n .then(\n async (content) =>\n // eslint-disable-next-line compat/compat\n await new Promise<ContentType<O> | undefined>((resolve, reject) => {\n decompressionMethods[compression ?? \"none\"](content, (error, result) => {\n if (error) {\n reject(error);\n } else {\n resolve((buffer ? result : result.toString()) as ContentType<O>);\n }\n });\n }),\n )\n .catch((error: unknown) => {\n throw error;\n });\n};\n\nexport default readFile;\n","import { readFileSync as nodeReadFileSync } from \"node:fs\";\nimport { brotliDecompressSync, unzipSync } from \"node:zlib\";\n\nimport { R_OK } from \"./constants\";\nimport PermissionError from \"./error/permission-error\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { ContentType, ReadFileOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst decompressionMethods = {\n brotli: brotliDecompressSync,\n gzip: unzipSync,\n none: (buffer: Buffer) => buffer,\n} as const;\n\nconst readFileSync = <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: URL | string,\n options?: O,\n): ContentType<O> => {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n if (!isAccessibleSync(path)) {\n throw new PermissionError(`unable to read the non-accessible file: ${path}`);\n }\n\n if (!isAccessibleSync(path, R_OK)) {\n throw new PermissionError(`invalid access to read file at: ${path}`);\n }\n\n const { buffer, compression, encoding, flag } = options ?? {};\n\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const content = nodeReadFileSync(path, flag ? { encoding, flag } : { encoding });\n\n const decompressed = decompressionMethods[compression ?? \"none\"](content);\n\n return (buffer ? decompressed : decompressed.toString()) as ContentType<O>;\n};\n\nexport default readFileSync;\n","import type { JsonValue } from \"type-fest\";\n\nimport readFile from \"./read-file\";\nimport type { JsonReviver, ReadJsonOptions } from \"./types\";\nimport parseJson from \"./utils/parse-json\";\nimport toPath from \"./utils/to-path\";\n\nasync function readJson<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): Promise<T>;\n\nasync function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): Promise<T>;\n// eslint-disable-next-line func-style\nasync function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver | ReadJsonOptions, options?: ReadJsonOptions): Promise<T> {\n if (typeof reviver === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n const content = await readFile(path, {\n buffer: true,\n encoding: undefined,\n });\n\n // Unlike `buffer.toString()` and `fs.readFile(path, 'utf8')`, `TextDecoder` will remove BOM.\n let data = new TextDecoder().decode(content);\n\n const { beforeParse, color } = options ?? {};\n\n if (typeof beforeParse === \"function\") {\n data = beforeParse(data);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parseJson<T>(data, reviver, toPath(path), { color });\n}\n\nexport default readJson;\n","import type { JsonValue } from \"type-fest\";\n\nimport readFileSync from \"./read-file-sync\";\nimport type { JsonReviver, ReadJsonOptions } from \"./types\";\nimport parseJson from \"./utils/parse-json\";\nimport toPath from \"./utils/to-path\";\n\nfunction readJsonSync<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): T;\n\nfunction readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): T;\n// eslint-disable-next-line func-style\nfunction readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver | ReadJsonOptions, options?: ReadJsonOptions): T {\n if (typeof reviver === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n const content = readFileSync(path, {\n buffer: true,\n encoding: undefined,\n });\n\n // Unlike `buffer.toString()` and `fs.readFile(path, 'utf8')`, `TextDecoder` will remove BOM.\n let data = new TextDecoder().decode(content);\n\n const { beforeParse, color } = options ?? {};\n\n if (typeof beforeParse === \"function\") {\n data = beforeParse(data);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parseJson<T>(data, reviver, toPath(path), { color });\n}\n\nexport default readJsonSync;\n","import { parse } from \"yaml\";\n\nimport readFile from \"./read-file\";\nimport type { ReadYamlOptions, YamlReviver } from \"./types\";\n\nasync function readYaml<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">): Promise<R>;\nasync function readYaml<R = Record<string, unknown>>(\n path: URL | string,\n reviver?: YamlReviver,\n options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">,\n): Promise<R>;\n\n// eslint-disable-next-line func-style\nasync function readYaml<R = Record<string, unknown>>(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n reviver?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\"> | YamlReviver,\n options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">,\n): Promise<R> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const {\n buffer,\n compression,\n encoding = \"utf8\",\n flag,\n ...parseOptions\n } = options ?? {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const content = await readFile(path, { buffer, compression, encoding, flag });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n return (typeof reviver === \"function\" ? parse(content, reviver, parseOptions) : parse(content, parseOptions)) as R;\n}\n\nexport default readYaml;\n","import { parse } from \"yaml\";\n\nimport readFileSync from \"./read-file-sync\";\nimport type { ReadYamlOptions, YamlReviver } from \"./types\";\n\nfunction readYamlSync<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">): R;\nfunction readYamlSync<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">): R;\n// eslint-disable-next-line func-style\nfunction readYamlSync<R = Record<string, unknown>>(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n reviver?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\"> | YamlReviver,\n options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">,\n): R {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const {\n buffer,\n compression,\n encoding = \"utf8\",\n flag,\n ...parseOptions\n } = options ?? {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const content = readFileSync(path, { buffer, compression, encoding, flag });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n return (typeof reviver === \"function\" ? parse(content, reviver, parseOptions) : parse(content, parseOptions)) as R;\n}\n\nexport default readYamlSync;\n","import type { Stats } from \"node:fs\";\nimport { chmod, chown, mkdir, rename, stat as nodeStat, unlink, writeFile as nodeWriteFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nimport { F_OK } from \"./constants\";\nimport isAccessible from \"./is-accessible\";\nimport type { WriteFileOptions } from \"./types\";\nimport assertValidFileContents from \"./utils/assert-valid-file-contents\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\nimport toUint8Array from \"./utils/to-uint-8-array\";\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeFile = async (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions): Promise<void> => {\n // eslint-disable-next-line no-param-reassign\n options = {\n encoding: \"utf8\",\n flag: \"w\",\n overwrite: true,\n recursive: true,\n ...options,\n };\n\n assertValidFileOrDirectoryPath(path);\n assertValidFileContents(content);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n const pathExists = await isAccessible(path, F_OK);\n\n if (!pathExists && options.recursive) {\n const directory = dirname(path);\n\n if (!(await isAccessible(directory, F_OK))) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await mkdir(directory, { recursive: true });\n }\n }\n\n let stat: Stats | undefined;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await nodeWriteFile(`${path}.tmp`, toUint8Array(content), { encoding: options.encoding, flag: options.flag });\n\n if (pathExists && !options.overwrite) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n stat = await nodeStat(path);\n\n if (options.chown === undefined) {\n // eslint-disable-next-line no-param-reassign\n options.chown = { gid: stat.gid, uid: stat.uid };\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await rename(path, `${path}.bak`);\n }\n\n const temporaryPath = `${path}.tmp`;\n\n if (options.chown) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await chown(temporaryPath, options.chown.uid, options.chown.gid);\n } catch {\n // On linux permissionless filesystems like exfat and fat32 the entire filesystem is normally owned by root,\n // and trying to chown it causes as permissions error.\n }\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await chmod(temporaryPath, stat && !options.mode ? stat.mode : options.mode ?? 0o666);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await rename(temporaryPath, path);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });\n } finally {\n if (await isAccessible(`${path}.tmp`)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await unlink(`${path}.tmp`);\n }\n }\n};\n\nexport default writeFile;\n","// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileContents = (contents: any): void => {\n if (typeof contents !== \"string\" && !(contents instanceof ArrayBuffer) && !ArrayBuffer.isView(contents)) {\n throw new TypeError(\"File contents must be a string, ArrayBuffer, or ArrayBuffer view.\");\n }\n};\n\nexport default assertValidFileContents;\n","const encoder = new TextEncoder();\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst toUint8Array = (contents: any) => {\n if (contents instanceof Uint8Array) {\n return contents;\n }\n\n if (typeof contents === \"string\") {\n return encoder.encode(contents);\n }\n\n if (contents instanceof ArrayBuffer) {\n return new Uint8Array(contents);\n }\n\n if (ArrayBuffer.isView(contents)) {\n const bytes = contents.buffer.slice(contents.byteOffset, contents.byteOffset + contents.byteLength);\n\n return new Uint8Array(bytes);\n }\n\n throw new TypeError(\"Invalid contents type. Expected string or ArrayBuffer.\");\n};\n\nexport default toUint8Array;\n","import type { Stats } from \"node:fs\";\nimport { chmodSync, chownSync, mkdirSync, renameSync, statSync, unlinkSync, writeFileSync as nodeWriteFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\n\nimport { F_OK } from \"./constants\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { WriteFileOptions } from \"./types\";\nimport assertValidFileContents from \"./utils/assert-valid-file-contents\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\nimport toUint8Array from \"./utils/to-uint-8-array\";\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeFileSync = (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions): void => {\n // eslint-disable-next-line no-param-reassign\n options = {\n encoding: \"utf8\",\n flag: \"w\",\n overwrite: true,\n recursive: true,\n ...options,\n };\n\n assertValidFileOrDirectoryPath(path);\n assertValidFileContents(content);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n const pathExists = isAccessibleSync(path, F_OK);\n\n if (!pathExists && options.recursive) {\n const directory = dirname(path);\n\n if (!isAccessibleSync(directory, F_OK)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(directory, { recursive: true });\n }\n }\n\n let stat: Stats | undefined;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n nodeWriteFileSync(`${path}.tmp`, toUint8Array(content), { encoding: options.encoding, flag: options.flag });\n\n if (pathExists && !options.overwrite) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n stat = statSync(path);\n\n if (options.chown === undefined) {\n // eslint-disable-next-line no-param-reassign\n options.chown = { gid: stat.gid, uid: stat.uid };\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n renameSync(path, `${path}.bak`);\n }\n\n const temporaryPath = `${path}.tmp`;\n\n if (options.chown) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n chownSync(temporaryPath, options.chown.uid, options.chown.gid);\n } catch {\n // On linux permissionless filesystems like exfat and fat32 the entire filesystem is normally owned by root,\n // and trying to chown it causes as permissions error.\n }\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n chmodSync(temporaryPath, stat && !options.mode ? stat.mode : options.mode ?? 0o666);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n renameSync(temporaryPath, path);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });\n } finally {\n if (isAccessibleSync(`${path}.tmp`)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n unlinkSync(`${path}.tmp`);\n }\n }\n};\n\nexport default writeFileSync;\n","import { readFile } from \"node:fs/promises\";\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport detectIndentFn from \"detect-indent\";\n\nimport { R_OK } from \"./constants\";\nimport isAccessible from \"./is-accessible\";\nimport type { WriteJsonOptions } from \"./types\";\nimport writeFile from \"./write-file\";\n\nconst writeJson = async (path: URL | string, data: unknown, options: WriteJsonOptions = {}): Promise<void> => {\n const { detectIndent, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: \"\\t\", ...options };\n\n let indent = indentOption;\n let trailingNewline = \"\\n\";\n\n if (await isAccessible(path, R_OK)) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const file = await readFile(path, \"utf8\");\n\n if (detectIndent) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const { indent: dIndent } = detectIndentFn(file);\n\n indent = dIndent as string;\n }\n\n trailingNewline = file.endsWith(\"\\n\") ? \"\\n\" : \"\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n }\n }\n\n // @ts-expect-error - `replacer` is a valid argument for `JSON.stringify`\n const json = stringify(data, replacer, indent);\n\n await writeFile(path, `${json}${trailingNewline}`, writeOptions);\n};\n\nexport default writeJson;\n","// Detect either spaces or tabs but not both to properly handle tabs for indentation and spaces for alignment\nconst INDENT_REGEX = /^(?:( )+|\\t+)/;\n\nconst INDENT_TYPE_SPACE = 'space';\nconst INDENT_TYPE_TAB = 'tab';\n\n/**\nMake a Map that counts how many indents/unindents have occurred for a given size and how many lines follow a given indentation.\n\nThe key is a concatenation of the indentation type (s = space and t = tab) and the size of the indents/unindents.\n\n```\nindents = {\n\tt3: [1, 0],\n\tt4: [1, 5],\n\ts5: [1, 0],\n\ts12: [1, 0],\n}\n```\n*/\nfunction makeIndentsMap(string, ignoreSingleSpaces) {\n\tconst indents = new Map();\n\n\t// Remember the size of previous line's indentation\n\tlet previousSize = 0;\n\tlet previousIndentType;\n\n\t// Indents key (ident type + size of the indents/unindents)\n\tlet key;\n\n\tfor (const line of string.split(/\\n/g)) {\n\t\tif (!line) {\n\t\t\t// Ignore empty lines\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet indent;\n\t\tlet indentType;\n\t\tlet use;\n\t\tlet weight;\n\t\tlet entry;\n\t\tconst matches = line.match(INDENT_REGEX);\n\n\t\tif (matches === null) {\n\t\t\tpreviousSize = 0;\n\t\t\tpreviousIndentType = '';\n\t\t} else {\n\t\t\tindent = matches[0].length;\n\t\t\tindentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;\n\n\t\t\t// Ignore single space unless it's the only indent detected to prevent common false positives\n\t\t\tif (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (indentType !== previousIndentType) {\n\t\t\t\tpreviousSize = 0;\n\t\t\t}\n\n\t\t\tpreviousIndentType = indentType;\n\n\t\t\tuse = 1;\n\t\t\tweight = 0;\n\n\t\t\tconst indentDifference = indent - previousSize;\n\t\t\tpreviousSize = indent;\n\n\t\t\t// Previous line have same indent?\n\t\t\tif (indentDifference === 0) {\n\t\t\t\t// Not a new \"use\" of the current indent:\n\t\t\t\tuse = 0;\n\t\t\t\t// But do add a bit to it for breaking ties:\n\t\t\t\tweight = 1;\n\t\t\t\t// We use the key from previous loop\n\t\t\t} else {\n\t\t\t\tconst absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;\n\t\t\t\tkey = encodeIndentsKey(indentType, absoluteIndentDifference);\n\t\t\t}\n\n\t\t\t// Update the stats\n\t\t\tentry = indents.get(key);\n\t\t\tentry = entry === undefined ? [1, 0] : [entry[0] + use, entry[1] + weight];\n\n\t\t\tindents.set(key, entry);\n\t\t}\n\t}\n\n\treturn indents;\n}\n\n// Encode the indent type and amount as a string (e.g. 's4') for use as a compound key in the indents Map.\nfunction encodeIndentsKey(indentType, indentAmount) {\n\tconst typeCharacter = indentType === INDENT_TYPE_SPACE ? 's' : 't';\n\treturn typeCharacter + String(indentAmount);\n}\n\n// Extract the indent type and amount from a key of the indents Map.\nfunction decodeIndentsKey(indentsKey) {\n\tconst keyHasTypeSpace = indentsKey[0] === 's';\n\tconst type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;\n\n\tconst amount = Number(indentsKey.slice(1));\n\n\treturn {type, amount};\n}\n\n// Return the key (e.g. 's4') from the indents Map that represents the most common indent,\n// or return undefined if there are no indents.\nfunction getMostUsedKey(indents) {\n\tlet result;\n\tlet maxUsed = 0;\n\tlet maxWeight = 0;\n\n\tfor (const [key, [usedCount, weight]] of indents) {\n\t\tif (usedCount > maxUsed || (usedCount === maxUsed && weight > maxWeight)) {\n\t\t\tmaxUsed = usedCount;\n\t\t\tmaxWeight = weight;\n\t\t\tresult = key;\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction makeIndentString(type, amount) {\n\tconst indentCharacter = type === INDENT_TYPE_SPACE ? ' ' : '\\t';\n\treturn indentCharacter.repeat(amount);\n}\n\nexport default function detectIndent(string) {\n\tif (typeof string !== 'string') {\n\t\tthrow new TypeError('Expected a string');\n\t}\n\n\t// Identify indents while skipping single space indents to avoid common edge cases (e.g. code comments)\n\t// If no indents are identified, run again and include all indents for comprehensive detection\n\tlet indents = makeIndentsMap(string, true);\n\tif (indents.size === 0) {\n\t\tindents = makeIndentsMap(string, false);\n\t}\n\n\tconst keyOfMostUsedIndent = getMostUsedKey(indents);\n\n\tlet type;\n\tlet amount = 0;\n\tlet indent = '';\n\n\tif (keyOfMostUsedIndent !== undefined) {\n\t\t({type, amount} = decodeIndentsKey(keyOfMostUsedIndent));\n\t\tindent = makeIndentString(type, amount);\n\t}\n\n\treturn {\n\t\tamount,\n\t\ttype,\n\t\tindent,\n\t};\n}\n","import { readFileSync } from \"node:fs\";\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport detectIndentFn from \"detect-indent\";\n\nimport { R_OK } from \"./constants\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { WriteJsonOptions } from \"./types\";\nimport writeFileSync from \"./write-file-sync\";\n\nconst writeJsonSync = (path: URL | string, data: unknown, options: WriteJsonOptions = {}): void => {\n const { detectIndent, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: \"\\t\", ...options };\n\n let indent = indentOption;\n let trailingNewline = \"\\n\";\n\n if (isAccessibleSync(path, R_OK)) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const file = readFileSync(path, \"utf8\");\n\n if (detectIndent) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const { indent: dIndent } = detectIndentFn(file);\n\n indent = dIndent as string;\n }\n\n trailingNewline = file.endsWith(\"\\n\") ? \"\\n\" : \"\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n }\n }\n\n // @ts-expect-error - `replacer` is a valid argument for `JSON.stringify`\n const json = stringify(data, replacer, indent);\n\n writeFileSync(path, `${json}${trailingNewline}`, writeOptions);\n};\n\nexport default writeJsonSync;\n","import type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToStringOptions } from \"yaml\";\nimport { stringify } from \"yaml\";\n\nimport type { YamlReplacer } from \"./types\";\nimport writeFile from \"./write-file\";\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype Options = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions;\n\nasync function writeYaml(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n options?: Options,\n): Promise<void>;\nasync function writeYaml(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n replacer?: YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: Options | number | string,\n): Promise<void>;\n// eslint-disable-next-line func-style\nasync function writeYaml(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types\n data: any,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n replacer?: Options | YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: Options | number | string,\n): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const content = typeof replacer === \"function\" || Array.isArray(replacer) ? stringify(data, replacer, options) : stringify(data, replacer as YamlReplacer);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n await writeFile(path, content);\n}\n\nexport default writeYaml;\n","import type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToStringOptions } from \"yaml\";\nimport { stringify } from \"yaml\";\n\nimport type { YamlReplacer } from \"./types\";\nimport writeFileSync from \"./write-file-sync\";\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype Options = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions;\n\nfunction writeYamlSync(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n options?: Options,\n): void;\nfunction writeYamlSync(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n replacer?: YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: Options | number | string,\n): void;\n// eslint-disable-next-line func-style\nfunction writeYamlSync(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types\n data: any,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n replacer?: Options | YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: number | string | (CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions),\n): void {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const content = typeof replacer === \"function\" || Array.isArray(replacer) ? stringify(data, replacer, options) : stringify(data, replacer as YamlReplacer);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n writeFileSync(path, content);\n}\n\nexport default writeYamlSync;\n"]}
1
+ {"version":3,"sources":["../src/walk.ts","../src/utils/assert-valid-file-or-directory-path.ts","../src/utils/glob-to-regex.ts","../src/utils/walk-include.ts","../src/collect.ts","../src/walk-sync.ts","../src/collect-sync.ts","../src/constants.ts","../src/empty-dir.ts","../src/empty-dir-sync.ts","../src/eol.ts","../src/find-up.ts","../src/find-up-sync.ts","../src/is-accessible.ts","../src/is-accessible-sync.ts","../src/read-file.ts","../src/read-file-sync.ts","../src/read-json.ts","../src/read-json-sync.ts","../src/read-yaml.ts","../src/read-yaml-sync.ts","../src/remove.ts","../src/remove-sync.ts","../src/write-file.ts","../src/utils/assert-valid-file-contents.ts","../src/utils/to-uint-8-array.ts","../src/write-file-sync.ts","../src/write-json.ts","../../../node_modules/.pnpm/detect-indent@7.0.1/node_modules/detect-indent/index.js","../src/write-json-sync.ts","../src/write-yaml.ts","../src/write-yaml-sync.ts"],"names":["readdir","realpath","stat","basename","join","normalize","resolve","assertValidFileOrDirectoryPath","fileOrDirectoryPath","assert_valid_file_or_directory_path_default","globToRegExp","glob","reString","glob_to_regex_default","walkInclude","path","extensions","match","skip","extension","pattern","walk_include_default","_createWalkEntry","normalizePath","name","info","walk","directory","followSymlinks","includeDirectories","includeFiles","includeSymlinks","maxDepth","mappedMatch","mappedSkip","to_path_default","entry","error","walk_error_default","collect","options","config","entries","collect_default","readdirSync","realpathSync","statSync","walkSync","collectSync","collect_sync_default","F_OK","R_OK","W_OK","X_OK","FIND_UP_STOP","existsSync","mkdir","rm","emptyDir","dir","item","empty_dir_default","mkdirSync","rmSync","empty_dir_sync_default","platform","regDetect","LF","CRLF","EOL","detect","content","d","crlf","newline","lf","format","eol","dirname","isAbsolute","parse","findUp","cwd","root","stopPath","stopAt","type","getMatchers","currentDirectory","fileName","filePath","stats","find_up_default","findUpSync","find_up_sync_default","access","isAccessible","mode","is_accessible_default","accessSync","isAccessibleSync","is_accessible_sync_default","nodeReadFile","brotliDecompress","unzip","decompressionMethods","buffer","callback","readFile","permission_error_default","compression","encoding","flag","reject","result","read_file_default","nodeReadFileSync","brotliDecompressSync","unzipSync","readFileSync","decompressed","read_file_sync_default","readJson","reviver","data","beforeParse","color","parse_json_default","read_json_default","readJsonSync","read_json_sync_default","readYaml","parseOptions","read_yaml_default","readYamlSync","read_yaml_sync_default","unlink","remove","remove_default","unlinkSync","removeSync","remove_sync_default","chmod","chown","rename","nodeStat","nodeWriteFile","assertValidFileContents","contents","assert_valid_file_contents_default","encoder","toUint8Array","bytes","to_uint_8_array_default","writeFile","pathExists","temporaryPath","write_file_default","chmodSync","chownSync","renameSync","nodeWriteFileSync","writeFileSync","write_file_sync_default","INDENT_REGEX","INDENT_TYPE_SPACE","INDENT_TYPE_TAB","makeIndentsMap","string","ignoreSingleSpaces","indents","previousSize","previousIndentType","key","line","indent","indentType","use","weight","matches","indentDifference","absoluteIndentDifference","encodeIndentsKey","indentAmount","decodeIndentsKey","indentsKey","amount","getMostUsedKey","maxUsed","maxWeight","usedCount","makeIndentString","detectIndent","keyOfMostUsedIndent","writeJson","indentOption","replacer","stringify","writeOptions","trailingNewline","file","dIndent","json","write_json_default","writeJsonSync","write_json_sync_default","writeYaml","write_yaml_default","writeYamlSync","write_yaml_sync_default"],"mappings":"6HAMA,OAAS,WAAAA,GAAS,YAAAC,GAAU,QAAAC,OAAY,cACxC,OAAS,YAAAC,GAAU,QAAAC,GAAM,aAAAC,GAAW,WAAAC,OAAe,OCNnD,IAAMC,EAAkCC,GAAmC,CACvE,GAAI,CAACA,GAAwB,EAAEA,aAA+B,MAAQ,OAAOA,GAAwB,SACjG,MAAM,IAAI,UAAU,yCAAyC,CAErE,EAEOC,EAAQF,ECPf,IAAMG,EAAgBC,GAAyB,CAC3C,IAAMC,EAAWD,EAEZ,QAA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AAI;AAAA,EAAO,EAEnD,OAASnK,EAAY,CAEjB,GAAIA,EAAM,OAAS,SACf,MAAMA,CAEd,CAIJ,IAAMqK,EAAOL,EAAUzE,EAAMwE,EAAUrB,CAAM,EAE7CZ,EAAcpJ,EAAM,GAAG2L,CAAI,GAAGH,CAAe,GAAID,CAAY,CACjE,EAEOO,GAAQD,GC3Cf,OAAS,aAAAP,MAAiB,OAuB1B,eAAeS,GACX/L,EAEA6G,EAEAwE,EAEA5J,EACa,CAEb,IAAM+B,EAAU,OAAO6H,GAAa,YAAc,MAAM,QAAQA,CAAQ,EAAIC,EAAUzE,EAAMwE,EAAU5J,CAAO,EAAI6J,EAAUzE,EAAMwE,CAAwB,EAGzJ,MAAMvC,EAAU9I,EAAMwD,CAAO,CACjC,CAEA,IAAOwI,GAAQD,GCvCf,OAAS,aAAAT,MAAiB,OAuB1B,SAASW,GACLjM,EAEA6G,EAEAwE,EAEA5J,EACI,CAEJ,IAAM+B,EAAU,OAAO6H,GAAa,YAAc,MAAM,QAAQA,CAAQ,EAAIC,EAAUzE,EAAMwE,EAAU5J,CAAO,EAAI6J,EAAUzE,EAAMwE,CAAwB,EAGzJjC,EAAcpJ,EAAMwD,CAAO,CAC/B,CAEA,IAAO0I,GAAQD","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdir, realpath, stat } from \"node:fs/promises\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = async (path: string): Promise<WalkEntry> => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = await stat(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/**\n * Walks the file tree rooted at root, yielding each file or directory in the\n * tree filtered according to the given options.\n * Options:\n * - maxDepth?: number = Infinity;\n * - includeFiles?: boolean = true;\n * - includeDirs?: boolean = true;\n * - includeSymlinks?: boolean = true;\n * - followSymlinks?: boolean = false;\n * - extensions?: string[];\n * - match?: string | ReadonlyArray<string>;\n * - skip?: string | ReadonlyArray<string>;\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default async function* walk(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): AsyncIterableIterator<WalkEntry> {\n assertValidFileOrDirectoryPath(directory);\n\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield await _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,security/detect-non-literal-fs-filename,no-loops/no-loops\n for await (const entry of await readdir(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = await realpath(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walk(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileOrDirectoryPath = (fileOrDirectoryPath: any): void => {\n if (!fileOrDirectoryPath || (!(fileOrDirectoryPath instanceof URL) && typeof fileOrDirectoryPath !== \"string\")) {\n throw new TypeError(\"Path must be a non-empty string or URL.\");\n }\n};\n\nexport default assertValidFileOrDirectoryPath;\n","const globToRegExp = (glob: string): RegExp => {\n const reString = glob\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.\\*/g, \".([^/]*)\") // Replace .* with .([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\*\\*/g, \"(.*)\") // Replace ** with (.*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/(?<!\\.)\\*(?!\\*)/g, \"([^/]*)\") // Replace * (not preceded by . or followed by *) with ([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\?/g, \"[^/]\") // Replace ? with [^/]\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.(?!\\*)/g, \"\\\\.\") // Escape . that is not preceded by *\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\{/g, \"(\") // Replace { with (\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\}/g, \")\") // Replace } with )\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/,/g, \"|\") // Replace , with |\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\[!(.*?)\\]/g, \"[^$1]\"); // Replace [!number-number] with [^number-number]\n\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp,security/detect-non-literal-regexp\n return new RegExp(`^${reString}$`);\n};\n\nexport default globToRegExp;\n","const walkInclude = (path: string, extensions?: string[], match?: RegExp[], skip?: RegExp[]): boolean => {\n if (extensions && !extensions.some((extension): boolean => path.endsWith(extension))) {\n return false;\n }\n\n if (match && !match.some((pattern): boolean => pattern.test(path))) {\n return false;\n }\n\n return !(skip && skip.some((pattern): boolean => pattern.test(path)));\n};\n\nexport default walkInclude;\n","import type { WalkOptions } from \"./types\";\nimport walk from \"./walk\";\n\nconst collect = async (directory: string, options: WalkOptions = {}): Promise<string[]> => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for await (const entry of walk(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collect;\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n/** Create {@linkcode WalkEntry} for the `path` synchronously. */\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = (path: string): WalkEntry => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = statSync(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/** Same as {@linkcode walk} but uses synchronous ops */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default function* walkSync(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): IterableIterator<WalkEntry> {\n assertValidFileOrDirectoryPath(directory);\n\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops,security/detect-non-literal-fs-filename\n for (const entry of readdirSync(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = realpathSync(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walkSync(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","import type { WalkOptions } from \"./types\";\nimport walkSync from \"./walk-sync\";\n\nconst collectSync = (directory: string, options: WalkOptions = {}): string[] => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const entry of walkSync(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collectSync;\n","/** Is the path visible to the calling process? */\nexport const F_OK = 0; // constants?.F_OK\n\n/** Is the path readable to the calling process? */\nexport const R_OK = 4; // constants?.R_OK\n\n/** Is the path writable to the calling process? */\nexport const W_OK = 2; // constants?.W_OK\n\n/** Is the path executable to the calling process? */\nexport const X_OK = 1; // constants?.X_OK\n\nexport const FIND_UP_STOP = Symbol(\"findUpStop\");\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport { existsSync } from \"node:fs\";\nimport { mkdir, readdir, rm } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nimport type { EmptyDirOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/**\n * Ensures that a directory is empty.\n * Deletes directory contents if the directory is not empty.\n * If the directory does not exist, it is created.\n * The directory itself is not deleted.\n */\n// eslint-disable-next-line unicorn/prevent-abbreviations\nconst emptyDir = async (dir: URL | string, options?: EmptyDirOptions): Promise<void> => {\n assertValidFileOrDirectoryPath(dir);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(dir)) {\n // if not exist. then create it\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await mkdir(dir, { recursive: true });\n\n return;\n }\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax,security/detect-non-literal-fs-filename\n for await (const item of await readdir(dir)) {\n await rm(join(toPath(dir), item), { ...options, force: true, recursive: true });\n }\n}\n\nexport default emptyDir;\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport { existsSync, mkdirSync, readdirSync, rmSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nimport type { EmptyDirOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/**\n * Ensures that a directory is empty.\n * Deletes directory contents if the directory is not empty.\n * If the directory does not exist, it is created.\n * The directory itself is not deleted.\n */\n// eslint-disable-next-line unicorn/prevent-abbreviations\nconst emptyDir = (dir: URL | string, options?: EmptyDirOptions): void => {\n assertValidFileOrDirectoryPath(dir);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(dir)) {\n // if not exist. then create it\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(dir, { recursive: true });\n\n return;\n }\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax,security/detect-non-literal-fs-filename\n for (const item of readdirSync(dir)) {\n rmSync(join(toPath(dir), item), { ...options, force: true, recursive: true });\n }\n}\n\nexport default emptyDir;\n","import { platform } from \"node:process\";\n\nconst regDetect = /\\r?\\n/g;\n\n/** End-of-line character for POSIX platforms such as macOS and Linux. */\nexport const LF = \"\\n\" as const;\n\n/** End-of-line character for Windows platforms. */\nexport const CRLF = \"\\r\\n\" as const;\n\n/**\n * End-of-line character evaluated for the current platform.\n */\nexport const EOL: \"\\n\" | \"\\r\\n\" = platform === \"win32\" ? CRLF : LF;\n\n/**\n * Detect the EOL character for string input.\n * Returns null if no newline.\n */\nexport const detect = (content: string): typeof EOL | null => {\n const d = content.match(regDetect);\n\n if (!d || d.length === 0) {\n return null;\n }\n\n const crlf = d.filter((newline) => newline === CRLF).length;\n const lf = d.length - crlf;\n\n return crlf > lf ? CRLF : LF;\n};\n\n/**\n * Format the file to the targeted EOL.\n */\nexport const format = (content: string, eol: typeof EOL): string => content.replaceAll(regDetect, eol);\n","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, parse, resolve } from \"node:path\";\n\nimport { FIND_UP_STOP } from \"./constants\";\nimport type { FindUpOptions, Match } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: ReadonlyArray<string> | string[] | string | ((directory: string) => Match | Promise<Match>),\n options: FindUpOptions = {},\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): Promise<string | undefined> => {\n if (typeof name !== \"string\" && !Array.isArray(name) && typeof name !== \"function\") {\n throw new TypeError(\"The `name` argument must be of type `string` or `string[]`\");\n }\n\n const cwd = options.cwd ? toPath(options.cwd) : process.cwd();\n\n assertValidFileOrDirectoryPath(cwd);\n\n let directory = resolve(cwd);\n\n const { root } = parse(directory);\n const stopPath = toPath(options.stopAt ?? root);\n\n assertValidFileOrDirectoryPath(stopPath);\n\n const stopAt = resolve(directory, stopPath);\n const type = options.type ?? \"file\";\n\n const getMatchers = async function (currentDirectory: string): Promise<(string | typeof FIND_UP_STOP | undefined)[]> {\n if (typeof name === \"function\") {\n const match = await name(currentDirectory);\n\n return [match];\n }\n\n if (typeof name === \"string\") {\n return [name];\n }\n\n if (Array.isArray(name)) {\n return name as string[];\n }\n\n return [name];\n };\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n // eslint-disable-next-line no-await-in-loop,no-loops/no-loops,no-restricted-syntax\n for await (const fileName of await getMatchers(directory)) {\n if (fileName === FIND_UP_STOP) {\n return undefined;\n }\n\n if (fileName === undefined) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = await stat(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUp;\n","import { statSync } from \"node:fs\";\nimport { dirname, isAbsolute, parse, resolve } from \"node:path\";\n\nimport { FIND_UP_STOP } from \"./constants\";\nimport type { FindUpOptions, Match } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: ReadonlyArray<string> | string[] | string | ((directory: string) => Match),\n options: FindUpOptions = {},\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): string | undefined => {\n if (typeof name !== \"string\" && !Array.isArray(name) && typeof name !== \"function\") {\n throw new TypeError(\"The `name` argument must be of type `string` or `string[]`\");\n }\n\n const cwd = options.cwd ? toPath(options.cwd) : process.cwd();\n\n assertValidFileOrDirectoryPath(cwd);\n\n let directory = resolve(cwd);\n\n const { root } = parse(directory);\n const stopPath = toPath(options.stopAt ?? root);\n\n assertValidFileOrDirectoryPath(stopPath);\n\n const stopAt = resolve(directory, stopPath);\n const type = options.type ?? \"file\";\n\n const getMatchers = function (currentDirectory: string): (string | typeof FIND_UP_STOP | undefined)[] {\n if (typeof name === \"function\") {\n const match = name(currentDirectory);\n\n return [match];\n }\n\n if (typeof name === \"string\") {\n return [name];\n }\n\n if (Array.isArray(name)) {\n return name as string[];\n }\n\n return [name];\n };\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const fileName of getMatchers(directory)) {\n if (fileName === FIND_UP_STOP) {\n return undefined;\n }\n\n if (fileName === undefined) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = statSync(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUpSync;\n","import { access } from \"node:fs/promises\";\n\nimport { F_OK } from \"./constants\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/** Returns a Promise that resolves to a boolean indicating if the path is accessible or not. */\nasync function isAccessible(path: URL | string, mode?: number): Promise<boolean>;\n// eslint-disable-next-line func-style\nasync function isAccessible(path: URL | string, mode: number = F_OK): Promise<boolean> {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n await access(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessible;\n","import { accessSync } from \"node:fs\";\n\nimport { F_OK } from \"./constants\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/** Returns a boolean indicating if the path is accessible or not. */\nfunction isAccessibleSync(path: URL | string, mode?: number): boolean;\n// eslint-disable-next-line func-style\nfunction isAccessibleSync(path: URL | string, mode: number = F_OK): boolean {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n accessSync(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessibleSync;\n","import { readFile as nodeReadFile } from \"node:fs/promises\";\nimport { brotliDecompress, unzip } from \"node:zlib\";\n\nimport { R_OK } from \"./constants\";\nimport PermissionError from \"./error/permission-error\";\nimport isAccessible from \"./is-accessible\";\nimport type { ContentType, ReadFileOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst decompressionMethods = {\n brotli: brotliDecompress,\n gzip: unzip,\n none: (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => {\n callback(null, buffer);\n },\n} as const;\n\nconst readFile = async <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: URL | string,\n options?: O,\n): Promise<ContentType<O>> => {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n if (!(await isAccessible(path))) {\n throw new PermissionError(`unable to read the non-accessible file: ${path}`);\n }\n\n if (!(await isAccessible(path, R_OK))) {\n throw new Error(`Unable to read the non-readable file: ${path}`);\n }\n\n const { buffer, compression, encoding, flag } = options ?? {};\n\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n return await nodeReadFile(path, flag ? { encoding, flag } : { encoding })\n .then(\n async (content) =>\n // eslint-disable-next-line compat/compat\n await new Promise<ContentType<O> | undefined>((resolve, reject) => {\n decompressionMethods[compression ?? \"none\"](content, (error, result) => {\n if (error) {\n reject(error);\n } else {\n resolve((buffer ? result : result.toString()) as ContentType<O>);\n }\n });\n }),\n )\n .catch((error: unknown) => {\n throw error;\n });\n};\n\nexport default readFile;\n","import { readFileSync as nodeReadFileSync } from \"node:fs\";\nimport { brotliDecompressSync, unzipSync } from \"node:zlib\";\n\nimport { R_OK } from \"./constants\";\nimport PermissionError from \"./error/permission-error\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { ContentType, ReadFileOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst decompressionMethods = {\n brotli: brotliDecompressSync,\n gzip: unzipSync,\n none: (buffer: Buffer) => buffer,\n} as const;\n\nconst readFileSync = <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: URL | string,\n options?: O,\n): ContentType<O> => {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n if (!isAccessibleSync(path)) {\n throw new PermissionError(`unable to read the non-accessible file: ${path}`);\n }\n\n if (!isAccessibleSync(path, R_OK)) {\n throw new PermissionError(`invalid access to read file at: ${path}`);\n }\n\n const { buffer, compression, encoding, flag } = options ?? {};\n\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const content = nodeReadFileSync(path, flag ? { encoding, flag } : { encoding });\n\n const decompressed = decompressionMethods[compression ?? \"none\"](content);\n\n return (buffer ? decompressed : decompressed.toString()) as ContentType<O>;\n};\n\nexport default readFileSync;\n","import type { JsonValue } from \"type-fest\";\n\nimport readFile from \"./read-file\";\nimport type { JsonReviver, ReadJsonOptions } from \"./types\";\nimport parseJson from \"./utils/parse-json\";\nimport toPath from \"./utils/to-path\";\n\nasync function readJson<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): Promise<T>;\n\nasync function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): Promise<T>;\n// eslint-disable-next-line func-style\nasync function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver | ReadJsonOptions, options?: ReadJsonOptions): Promise<T> {\n if (typeof reviver === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n const content = await readFile(path, {\n buffer: true,\n encoding: undefined,\n });\n\n // Unlike `buffer.toString()` and `fs.readFile(path, 'utf8')`, `TextDecoder` will remove BOM.\n let data = new TextDecoder().decode(content);\n\n const { beforeParse, color } = options ?? {};\n\n if (typeof beforeParse === \"function\") {\n data = beforeParse(data);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parseJson<T>(data, reviver, toPath(path), { color });\n}\n\nexport default readJson;\n","import type { JsonValue } from \"type-fest\";\n\nimport readFileSync from \"./read-file-sync\";\nimport type { JsonReviver, ReadJsonOptions } from \"./types\";\nimport parseJson from \"./utils/parse-json\";\nimport toPath from \"./utils/to-path\";\n\nfunction readJsonSync<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): T;\n\nfunction readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): T;\n// eslint-disable-next-line func-style\nfunction readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver | ReadJsonOptions, options?: ReadJsonOptions): T {\n if (typeof reviver === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n const content = readFileSync(path, {\n buffer: true,\n encoding: undefined,\n });\n\n // Unlike `buffer.toString()` and `fs.readFile(path, 'utf8')`, `TextDecoder` will remove BOM.\n let data = new TextDecoder().decode(content);\n\n const { beforeParse, color } = options ?? {};\n\n if (typeof beforeParse === \"function\") {\n data = beforeParse(data);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parseJson<T>(data, reviver, toPath(path), { color });\n}\n\nexport default readJsonSync;\n","import { parse } from \"yaml\";\n\nimport readFile from \"./read-file\";\nimport type { ReadYamlOptions, YamlReviver } from \"./types\";\n\nasync function readYaml<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">): Promise<R>;\nasync function readYaml<R = Record<string, unknown>>(\n path: URL | string,\n reviver?: YamlReviver,\n options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">,\n): Promise<R>;\n\n// eslint-disable-next-line func-style\nasync function readYaml<R = Record<string, unknown>>(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n reviver?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\"> | YamlReviver,\n options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">,\n): Promise<R> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const {\n buffer,\n compression,\n encoding = \"utf8\",\n flag,\n ...parseOptions\n } = options ?? {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const content = await readFile(path, { buffer, compression, encoding, flag });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n return (typeof reviver === \"function\" ? parse(content, reviver, parseOptions) : parse(content, parseOptions)) as R;\n}\n\nexport default readYaml;\n","import { parse } from \"yaml\";\n\nimport readFileSync from \"./read-file-sync\";\nimport type { ReadYamlOptions, YamlReviver } from \"./types\";\n\nfunction readYamlSync<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">): R;\nfunction readYamlSync<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">): R;\n// eslint-disable-next-line func-style\nfunction readYamlSync<R = Record<string, unknown>>(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n reviver?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\"> | YamlReviver,\n options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">,\n): R {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const {\n buffer,\n compression,\n encoding = \"utf8\",\n flag,\n ...parseOptions\n } = options ?? {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const content = readFileSync(path, { buffer, compression, encoding, flag });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n return (typeof reviver === \"function\" ? parse(content, reviver, parseOptions) : parse(content, parseOptions)) as R;\n}\n\nexport default readYamlSync;\n","import { rm, unlink } from \"node:fs/promises\";\n\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\n\nconst remove = async (\n path: URL | string,\n options: {\n /**\n * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or\n * `EPERM` error is encountered, Node.js will retry the operation with a linear\n * backoff wait of `retryDelay` ms longer on each try. This option represents the\n * number of retries. This option is ignored if the `recursive` option is not\n * `true`.\n * @default 0\n */\n maxRetries?: number | undefined;\n /**\n * The amount of time in milliseconds to wait between retries.\n * This option is ignored if the `recursive` option is not `true`.\n * @default 100\n */\n retryDelay?: number | undefined;\n } = {},\n): Promise<void> => {\n assertValidFileOrDirectoryPath(path);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await unlink(path);\n } catch {\n /* empty */\n }\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n await rm(path, { force: true, maxRetries: options?.maxRetries, recursive: true, retryDelay: options?.retryDelay });\n } catch {\n /* empty */\n }\n};\n\nexport default remove;\n","import { rmSync, unlinkSync } from \"node:fs\";\n\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\n\nconst removeSync = (\n path: URL | string,\n options: {\n /**\n * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or\n * `EPERM` error is encountered, Node.js will retry the operation with a linear\n * backoff wait of `retryDelay` ms longer on each try. This option represents the\n * number of retries. This option is ignored if the `recursive` option is not\n * `true`.\n * @default 0\n */\n maxRetries?: number | undefined;\n /**\n * The amount of time in milliseconds to wait between retries.\n * This option is ignored if the `recursive` option is not `true`.\n * @default 100\n */\n retryDelay?: number | undefined;\n } = {},\n): void => {\n assertValidFileOrDirectoryPath(path);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n unlinkSync(path);\n } catch {\n /* empty */\n }\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n rmSync(path, { force: true, maxRetries: options?.maxRetries, recursive: true, retryDelay: options?.retryDelay });\n } catch {\n /* empty */\n }\n};\n\nexport default removeSync;\n","import type { Stats } from \"node:fs\";\nimport { chmod, chown, mkdir, rename, stat as nodeStat, unlink, writeFile as nodeWriteFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nimport { F_OK } from \"./constants\";\nimport isAccessible from \"./is-accessible\";\nimport type { WriteFileOptions } from \"./types\";\nimport assertValidFileContents from \"./utils/assert-valid-file-contents\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\nimport toUint8Array from \"./utils/to-uint-8-array\";\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeFile = async (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions): Promise<void> => {\n // eslint-disable-next-line no-param-reassign\n options = {\n encoding: \"utf8\",\n flag: \"w\",\n overwrite: true,\n recursive: true,\n ...options,\n };\n\n assertValidFileOrDirectoryPath(path);\n assertValidFileContents(content);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n const pathExists = await isAccessible(path, F_OK);\n\n if (!pathExists && options.recursive) {\n const directory = dirname(path);\n\n if (!(await isAccessible(directory, F_OK))) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await mkdir(directory, { recursive: true });\n }\n }\n\n let stat: Stats | undefined;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await nodeWriteFile(`${path}.tmp`, toUint8Array(content), { encoding: options.encoding, flag: options.flag });\n\n if (pathExists && !options.overwrite) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n stat = await nodeStat(path);\n\n if (options.chown === undefined) {\n // eslint-disable-next-line no-param-reassign\n options.chown = { gid: stat.gid, uid: stat.uid };\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await rename(path, `${path}.bak`);\n }\n\n const temporaryPath = `${path}.tmp`;\n\n if (options.chown) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await chown(temporaryPath, options.chown.uid, options.chown.gid);\n } catch {\n // On linux permissionless filesystems like exfat and fat32 the entire filesystem is normally owned by root,\n // and trying to chown it causes as permissions error.\n }\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await chmod(temporaryPath, stat && !options.mode ? stat.mode : options.mode ?? 0o666);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await rename(temporaryPath, path);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });\n } finally {\n if (await isAccessible(`${path}.tmp`)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await unlink(`${path}.tmp`);\n }\n }\n};\n\nexport default writeFile;\n","// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileContents = (contents: any): void => {\n if (typeof contents !== \"string\" && !(contents instanceof ArrayBuffer) && !ArrayBuffer.isView(contents)) {\n throw new TypeError(\"File contents must be a string, ArrayBuffer, or ArrayBuffer view.\");\n }\n};\n\nexport default assertValidFileContents;\n","const encoder = new TextEncoder();\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst toUint8Array = (contents: any) => {\n if (contents instanceof Uint8Array) {\n return contents;\n }\n\n if (typeof contents === \"string\") {\n return encoder.encode(contents);\n }\n\n if (contents instanceof ArrayBuffer) {\n return new Uint8Array(contents);\n }\n\n if (ArrayBuffer.isView(contents)) {\n const bytes = contents.buffer.slice(contents.byteOffset, contents.byteOffset + contents.byteLength);\n\n return new Uint8Array(bytes);\n }\n\n throw new TypeError(\"Invalid contents type. Expected string or ArrayBuffer.\");\n};\n\nexport default toUint8Array;\n","import type { Stats } from \"node:fs\";\nimport { chmodSync, chownSync, mkdirSync, renameSync, statSync, unlinkSync, writeFileSync as nodeWriteFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\n\nimport { F_OK } from \"./constants\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { WriteFileOptions } from \"./types\";\nimport assertValidFileContents from \"./utils/assert-valid-file-contents\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\nimport toUint8Array from \"./utils/to-uint-8-array\";\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeFileSync = (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions): void => {\n // eslint-disable-next-line no-param-reassign\n options = {\n encoding: \"utf8\",\n flag: \"w\",\n overwrite: true,\n recursive: true,\n ...options,\n };\n\n assertValidFileOrDirectoryPath(path);\n assertValidFileContents(content);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n const pathExists = isAccessibleSync(path, F_OK);\n\n if (!pathExists && options.recursive) {\n const directory = dirname(path);\n\n if (!isAccessibleSync(directory, F_OK)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(directory, { recursive: true });\n }\n }\n\n let stat: Stats | undefined;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n nodeWriteFileSync(`${path}.tmp`, toUint8Array(content), { encoding: options.encoding, flag: options.flag });\n\n if (pathExists && !options.overwrite) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n stat = statSync(path);\n\n if (options.chown === undefined) {\n // eslint-disable-next-line no-param-reassign\n options.chown = { gid: stat.gid, uid: stat.uid };\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n renameSync(path, `${path}.bak`);\n }\n\n const temporaryPath = `${path}.tmp`;\n\n if (options.chown) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n chownSync(temporaryPath, options.chown.uid, options.chown.gid);\n } catch {\n // On linux permissionless filesystems like exfat and fat32 the entire filesystem is normally owned by root,\n // and trying to chown it causes as permissions error.\n }\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n chmodSync(temporaryPath, stat && !options.mode ? stat.mode : options.mode ?? 0o666);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n renameSync(temporaryPath, path);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });\n } finally {\n if (isAccessibleSync(`${path}.tmp`)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n unlinkSync(`${path}.tmp`);\n }\n }\n};\n\nexport default writeFileSync;\n","import { readFile } from \"node:fs/promises\";\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport detectIndentFn from \"detect-indent\";\n\nimport { R_OK } from \"./constants\";\nimport isAccessible from \"./is-accessible\";\nimport type { WriteJsonOptions } from \"./types\";\nimport writeFile from \"./write-file\";\n\nconst writeJson = async (path: URL | string, data: unknown, options: WriteJsonOptions = {}): Promise<void> => {\n const { detectIndent, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: \"\\t\", ...options };\n\n let indent = indentOption;\n let trailingNewline = \"\\n\";\n\n if (await isAccessible(path, R_OK)) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const file = await readFile(path, \"utf8\");\n\n if (detectIndent) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const { indent: dIndent } = detectIndentFn(file);\n\n indent = dIndent as string;\n }\n\n trailingNewline = file.endsWith(\"\\n\") ? \"\\n\" : \"\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n }\n }\n\n // @ts-expect-error - `replacer` is a valid argument for `JSON.stringify`\n const json = stringify(data, replacer, indent);\n\n await writeFile(path, `${json}${trailingNewline}`, writeOptions);\n};\n\nexport default writeJson;\n","// Detect either spaces or tabs but not both to properly handle tabs for indentation and spaces for alignment\nconst INDENT_REGEX = /^(?:( )+|\\t+)/;\n\nconst INDENT_TYPE_SPACE = 'space';\nconst INDENT_TYPE_TAB = 'tab';\n\n/**\nMake a Map that counts how many indents/unindents have occurred for a given size and how many lines follow a given indentation.\n\nThe key is a concatenation of the indentation type (s = space and t = tab) and the size of the indents/unindents.\n\n```\nindents = {\n\tt3: [1, 0],\n\tt4: [1, 5],\n\ts5: [1, 0],\n\ts12: [1, 0],\n}\n```\n*/\nfunction makeIndentsMap(string, ignoreSingleSpaces) {\n\tconst indents = new Map();\n\n\t// Remember the size of previous line's indentation\n\tlet previousSize = 0;\n\tlet previousIndentType;\n\n\t// Indents key (ident type + size of the indents/unindents)\n\tlet key;\n\n\tfor (const line of string.split(/\\n/g)) {\n\t\tif (!line) {\n\t\t\t// Ignore empty lines\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet indent;\n\t\tlet indentType;\n\t\tlet use;\n\t\tlet weight;\n\t\tlet entry;\n\t\tconst matches = line.match(INDENT_REGEX);\n\n\t\tif (matches === null) {\n\t\t\tpreviousSize = 0;\n\t\t\tpreviousIndentType = '';\n\t\t} else {\n\t\t\tindent = matches[0].length;\n\t\t\tindentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;\n\n\t\t\t// Ignore single space unless it's the only indent detected to prevent common false positives\n\t\t\tif (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (indentType !== previousIndentType) {\n\t\t\t\tpreviousSize = 0;\n\t\t\t}\n\n\t\t\tpreviousIndentType = indentType;\n\n\t\t\tuse = 1;\n\t\t\tweight = 0;\n\n\t\t\tconst indentDifference = indent - previousSize;\n\t\t\tpreviousSize = indent;\n\n\t\t\t// Previous line have same indent?\n\t\t\tif (indentDifference === 0) {\n\t\t\t\t// Not a new \"use\" of the current indent:\n\t\t\t\tuse = 0;\n\t\t\t\t// But do add a bit to it for breaking ties:\n\t\t\t\tweight = 1;\n\t\t\t\t// We use the key from previous loop\n\t\t\t} else {\n\t\t\t\tconst absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;\n\t\t\t\tkey = encodeIndentsKey(indentType, absoluteIndentDifference);\n\t\t\t}\n\n\t\t\t// Update the stats\n\t\t\tentry = indents.get(key);\n\t\t\tentry = entry === undefined ? [1, 0] : [entry[0] + use, entry[1] + weight];\n\n\t\t\tindents.set(key, entry);\n\t\t}\n\t}\n\n\treturn indents;\n}\n\n// Encode the indent type and amount as a string (e.g. 's4') for use as a compound key in the indents Map.\nfunction encodeIndentsKey(indentType, indentAmount) {\n\tconst typeCharacter = indentType === INDENT_TYPE_SPACE ? 's' : 't';\n\treturn typeCharacter + String(indentAmount);\n}\n\n// Extract the indent type and amount from a key of the indents Map.\nfunction decodeIndentsKey(indentsKey) {\n\tconst keyHasTypeSpace = indentsKey[0] === 's';\n\tconst type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;\n\n\tconst amount = Number(indentsKey.slice(1));\n\n\treturn {type, amount};\n}\n\n// Return the key (e.g. 's4') from the indents Map that represents the most common indent,\n// or return undefined if there are no indents.\nfunction getMostUsedKey(indents) {\n\tlet result;\n\tlet maxUsed = 0;\n\tlet maxWeight = 0;\n\n\tfor (const [key, [usedCount, weight]] of indents) {\n\t\tif (usedCount > maxUsed || (usedCount === maxUsed && weight > maxWeight)) {\n\t\t\tmaxUsed = usedCount;\n\t\t\tmaxWeight = weight;\n\t\t\tresult = key;\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction makeIndentString(type, amount) {\n\tconst indentCharacter = type === INDENT_TYPE_SPACE ? ' ' : '\\t';\n\treturn indentCharacter.repeat(amount);\n}\n\nexport default function detectIndent(string) {\n\tif (typeof string !== 'string') {\n\t\tthrow new TypeError('Expected a string');\n\t}\n\n\t// Identify indents while skipping single space indents to avoid common edge cases (e.g. code comments)\n\t// If no indents are identified, run again and include all indents for comprehensive detection\n\tlet indents = makeIndentsMap(string, true);\n\tif (indents.size === 0) {\n\t\tindents = makeIndentsMap(string, false);\n\t}\n\n\tconst keyOfMostUsedIndent = getMostUsedKey(indents);\n\n\tlet type;\n\tlet amount = 0;\n\tlet indent = '';\n\n\tif (keyOfMostUsedIndent !== undefined) {\n\t\t({type, amount} = decodeIndentsKey(keyOfMostUsedIndent));\n\t\tindent = makeIndentString(type, amount);\n\t}\n\n\treturn {\n\t\tamount,\n\t\ttype,\n\t\tindent,\n\t};\n}\n","import { readFileSync } from \"node:fs\";\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport detectIndentFn from \"detect-indent\";\n\nimport { R_OK } from \"./constants\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { WriteJsonOptions } from \"./types\";\nimport writeFileSync from \"./write-file-sync\";\n\nconst writeJsonSync = (path: URL | string, data: unknown, options: WriteJsonOptions = {}): void => {\n const { detectIndent, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: \"\\t\", ...options };\n\n let indent = indentOption;\n let trailingNewline = \"\\n\";\n\n if (isAccessibleSync(path, R_OK)) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const file = readFileSync(path, \"utf8\");\n\n if (detectIndent) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const { indent: dIndent } = detectIndentFn(file);\n\n indent = dIndent as string;\n }\n\n trailingNewline = file.endsWith(\"\\n\") ? \"\\n\" : \"\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n }\n }\n\n // @ts-expect-error - `replacer` is a valid argument for `JSON.stringify`\n const json = stringify(data, replacer, indent);\n\n writeFileSync(path, `${json}${trailingNewline}`, writeOptions);\n};\n\nexport default writeJsonSync;\n","import type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToStringOptions } from \"yaml\";\nimport { stringify } from \"yaml\";\n\nimport type { YamlReplacer } from \"./types\";\nimport writeFile from \"./write-file\";\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype Options = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions;\n\nasync function writeYaml(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n options?: Options,\n): Promise<void>;\nasync function writeYaml(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n replacer?: YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: Options | number | string,\n): Promise<void>;\n// eslint-disable-next-line func-style\nasync function writeYaml(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types\n data: any,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n replacer?: Options | YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: Options | number | string,\n): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const content = typeof replacer === \"function\" || Array.isArray(replacer) ? stringify(data, replacer, options) : stringify(data, replacer as YamlReplacer);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n await writeFile(path, content);\n}\n\nexport default writeYaml;\n","import type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToStringOptions } from \"yaml\";\nimport { stringify } from \"yaml\";\n\nimport type { YamlReplacer } from \"./types\";\nimport writeFileSync from \"./write-file-sync\";\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype Options = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions;\n\nfunction writeYamlSync(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n options?: Options,\n): void;\nfunction writeYamlSync(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n replacer?: YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: Options | number | string,\n): void;\n// eslint-disable-next-line func-style\nfunction writeYamlSync(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types\n data: any,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n replacer?: Options | YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: number | string | (CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions),\n): void {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const content = typeof replacer === \"function\" || Array.isArray(replacer) ? stringify(data, replacer, options) : stringify(data, replacer as YamlReplacer);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n writeFileSync(path, content);\n}\n\nexport default writeYamlSync;\n"]}
package/dist/index.d.cts CHANGED
@@ -42,6 +42,16 @@ declare function readYaml<R = Record<string, unknown>>(path: URL | string, reviv
42
42
  declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): R;
43
43
  declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): R;
44
44
 
45
+ declare const remove: (path: URL | string, options?: {
46
+ maxRetries?: number | undefined;
47
+ retryDelay?: number | undefined;
48
+ }) => Promise<void>;
49
+
50
+ declare const removeSync: (path: URL | string, options?: {
51
+ maxRetries?: number | undefined;
52
+ retryDelay?: number | undefined;
53
+ }) => void;
54
+
45
55
  declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
46
56
 
47
57
  declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
@@ -62,4 +72,4 @@ type Options = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOption
62
72
  declare function writeYamlSync(path: URL | string, data: any, options?: Options): void;
63
73
  declare function writeYamlSync(path: URL | string, data: any, replacer?: YamlReplacer, options?: Options | number | string): void;
64
74
 
65
- export { CRLF, EOL, EmptyDirOptions, FindUpOptions, JsonReviver, LF, ReadFileOptions, ReadJsonOptions, WalkEntry, WalkOptions, WriteFileOptions, WriteJsonOptions, YamlReplacer, collect, collectSync, detect, emptyDir$1 as emptyDir, emptyDir as emptyDirSync, findUp, findUpSync, format, isAccessible, isAccessibleSync, readFile, readFileSync, readJson, readJsonSync, readYaml, readYamlSync, walk, walkSync, writeFile, writeFileSync, writeJson, writeJsonSync, writeYaml, writeYamlSync };
75
+ export { CRLF, EOL, EmptyDirOptions, FindUpOptions, JsonReviver, LF, ReadFileOptions, ReadJsonOptions, WalkEntry, WalkOptions, WriteFileOptions, WriteJsonOptions, YamlReplacer, collect, collectSync, detect, emptyDir$1 as emptyDir, emptyDir as emptyDirSync, findUp, findUpSync, format, isAccessible, isAccessibleSync, readFile, readFileSync, readJson, readJsonSync, readYaml, readYamlSync, remove, removeSync, walk, walkSync, writeFile, writeFileSync, writeJson, writeJsonSync, writeYaml, writeYamlSync };
package/dist/index.d.ts CHANGED
@@ -42,6 +42,16 @@ declare function readYaml<R = Record<string, unknown>>(path: URL | string, reviv
42
42
  declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): R;
43
43
  declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): R;
44
44
 
45
+ declare const remove: (path: URL | string, options?: {
46
+ maxRetries?: number | undefined;
47
+ retryDelay?: number | undefined;
48
+ }) => Promise<void>;
49
+
50
+ declare const removeSync: (path: URL | string, options?: {
51
+ maxRetries?: number | undefined;
52
+ retryDelay?: number | undefined;
53
+ }) => void;
54
+
45
55
  declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
46
56
 
47
57
  declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
@@ -62,4 +72,4 @@ type Options = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOption
62
72
  declare function writeYamlSync(path: URL | string, data: any, options?: Options): void;
63
73
  declare function writeYamlSync(path: URL | string, data: any, replacer?: YamlReplacer, options?: Options | number | string): void;
64
74
 
65
- export { CRLF, EOL, EmptyDirOptions, FindUpOptions, JsonReviver, LF, ReadFileOptions, ReadJsonOptions, WalkEntry, WalkOptions, WriteFileOptions, WriteJsonOptions, YamlReplacer, collect, collectSync, detect, emptyDir$1 as emptyDir, emptyDir as emptyDirSync, findUp, findUpSync, format, isAccessible, isAccessibleSync, readFile, readFileSync, readJson, readJsonSync, readYaml, readYamlSync, walk, walkSync, writeFile, writeFileSync, writeJson, writeJsonSync, writeYaml, writeYamlSync };
75
+ export { CRLF, EOL, EmptyDirOptions, FindUpOptions, JsonReviver, LF, ReadFileOptions, ReadJsonOptions, WalkEntry, WalkOptions, WriteFileOptions, WriteJsonOptions, YamlReplacer, collect, collectSync, detect, emptyDir$1 as emptyDir, emptyDir as emptyDirSync, findUp, findUpSync, format, isAccessible, isAccessibleSync, readFile, readFileSync, readJson, readJsonSync, readYaml, readYamlSync, remove, removeSync, walk, walkSync, writeFile, writeFileSync, writeJson, writeJsonSync, writeYaml, writeYamlSync };
package/dist/index.js CHANGED
@@ -1,23 +1,23 @@
1
- import { a as a$1, b as b$1 } from './chunk-3EHZOWRU.js';
2
- import { a, b as b$2 } from './chunk-4WZBYISP.js';
1
+ import { a as a$1, b } from './chunk-3EHZOWRU.js';
2
+ import { a, b as b$1 } from './chunk-4WZBYISP.js';
3
3
  import './chunk-UPN3Y5W3.js';
4
- import { readdir, realpath, stat, mkdir, rm, access, readFile, writeFile, rename, chown, chmod, unlink } from 'node:fs/promises';
4
+ import { readdir, realpath, stat, mkdir, rm, access, readFile, unlink, writeFile, rename, chown, chmod } from 'node:fs/promises';
5
5
  import { resolve, join, normalize, basename, parse, isAbsolute, dirname } from 'node:path';
6
- import { readdirSync, realpathSync, statSync, existsSync, mkdirSync, rmSync, accessSync, readFileSync, writeFileSync, renameSync, chownSync, chmodSync, unlinkSync } from 'node:fs';
6
+ import { readdirSync, realpathSync, statSync, existsSync, mkdirSync, rmSync, accessSync, readFileSync, unlinkSync, writeFileSync, renameSync, chownSync, chmodSync } from 'node:fs';
7
7
  import { platform } from 'node:process';
8
8
  import { brotliDecompress, unzip, brotliDecompressSync, unzipSync } from 'node:zlib';
9
9
  import { parse as parse$1, stringify } from 'yaml';
10
10
 
11
- var Q=t=>{if(!t||!(t instanceof URL)&&typeof t!="string")throw new TypeError("Path must be a non-empty string or URL.")},u=Q;var Z=t=>{let e=t.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${e}$`)},b=Z;var tt=(t,e,r,o)=>e&&!e.some(n=>t.endsWith(n))||r&&!r.some(n=>n.test(t))?!1:!(o&&o.some(n=>n.test(t))),w=tt;var ft=async t=>{let e=normalize(t),r=basename(e),o=await stat(e);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:e}};async function*x(t,{extensions:e,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a$2,maxDepth:c=Number.POSITIVE_INFINITY,skip:y}={}){if(u(t),c<0)return;let f=a$2?a$2.map(i=>typeof i=="string"?b(i):i):void 0,m=y?y.map(i=>typeof i=="string"?b(i):i):void 0;if(t=resolve(a(t)),o&&w(t,e,f,m)&&(yield await ft(t)),!(c<1||!w(t,void 0,void 0,m)))try{for await(let i of await readdir(t,{withFileTypes:!0})){let g=join(t,i.name);if(i.isSymbolicLink())if(r)g=await realpath(g);else if(s&&w(g,e,f,m))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:g};else continue;i.isSymbolicLink()||i.isDirectory()?yield*x(g,{extensions:e,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:s,match:f,maxDepth:c-1,skip:m}):i.isFile()&&n&&w(g,e,f,m)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:g});}}catch(i){throw i instanceof a$1?i:new a$1(i,t)}}var ct=async(t,e={})=>{let r={extensions:["js","mjs","cjs","ts"],...e},o=[];for await(let n of x(t,r))o.push(n.path);return o},mt=ct;var Ot=t=>{let e=normalize(t),r=basename(e),o=statSync(e);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:e}};function*P(t,{extensions:e,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a$2,maxDepth:c=Number.POSITIVE_INFINITY,skip:y}={}){if(u(t),c<0)return;let f=a$2?a$2.map(i=>typeof i=="string"?b(i):i):void 0,m=y?y.map(i=>typeof i=="string"?b(i):i):void 0;if(t=resolve(a(t)),o&&w(t,e,f,m)&&(yield Ot(t)),!(c<1||!w(t,void 0,void 0,m)))try{for(let i of readdirSync(t,{withFileTypes:!0})){let g=join(t,i.name);if(i.isSymbolicLink())if(r)g=realpathSync(g);else if(s&&w(g,e,f,m))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:g};else continue;i.isSymbolicLink()||i.isDirectory()?yield*P(g,{extensions:e,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:s,match:f,maxDepth:c-1,skip:m}):i.isFile()&&n&&w(g,e,f,m)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:g});}}catch(i){throw i instanceof a$1?i:new a$1(i,t)}}var Rt=(t,e={})=>{let r={extensions:["js","mjs","cjs","ts"],...e},o=[];for(let n of P(t,r))o.push(n.path);return o},St=Rt;var S=0,k=4,ht=2,bt=1,T=Symbol("findUpStop");var Et=async(t,e)=>{if(u(t),!existsSync(t)){await mkdir(t,{recursive:!0});return}for await(let r of await readdir(t))await rm(join(a(t),r),{...e,force:!0,recursive:!0});},Lt=Et;var Yt=(t,e)=>{if(u(t),!existsSync(t)){mkdirSync(t,{recursive:!0});return}for(let r of readdirSync(t))rmSync(join(a(t),r),{...e,force:!0,recursive:!0});},Wt=Yt;var C=/\r?\n/g,N=`
11
+ var Q=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},y=Q;var Z=e=>{let t=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${t}$`)},h=Z;var ee=(e,t,r,o)=>t&&!t.some(n=>e.endsWith(n))||r&&!r.some(n=>n.test(e))?!1:!(o&&o.some(n=>n.test(e))),w=ee;var fe=async e=>{let t=normalize(e),r=basename(t),o=await stat(t);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:t}};async function*x(e,{extensions:t,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a$2,maxDepth:c=Number.POSITIVE_INFINITY,skip:u}={}){if(y(e),c<0)return;let f=a$2?a$2.map(i=>typeof i=="string"?h(i):i):void 0,l=u?u.map(i=>typeof i=="string"?h(i):i):void 0;if(e=resolve(a(e)),o&&w(e,t,f,l)&&(yield await fe(e)),!(c<1||!w(e,void 0,void 0,l)))try{for await(let i of await readdir(e,{withFileTypes:!0})){let g=join(e,i.name);if(i.isSymbolicLink())if(r)g=await realpath(g);else if(s&&w(g,t,f,l))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:g};else continue;i.isSymbolicLink()||i.isDirectory()?yield*x(g,{extensions:t,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:s,match:f,maxDepth:c-1,skip:l}):i.isFile()&&n&&w(g,t,f,l)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:g});}}catch(i){throw i instanceof a$1?i:new a$1(i,e)}}var ce=async(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},o=[];for await(let n of x(e,r))o.push(n.path);return o},me=ce;var Oe=e=>{let t=normalize(e),r=basename(t),o=statSync(t);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:t}};function*P(e,{extensions:t,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a$2,maxDepth:c=Number.POSITIVE_INFINITY,skip:u}={}){if(y(e),c<0)return;let f=a$2?a$2.map(i=>typeof i=="string"?h(i):i):void 0,l=u?u.map(i=>typeof i=="string"?h(i):i):void 0;if(e=resolve(a(e)),o&&w(e,t,f,l)&&(yield Oe(e)),!(c<1||!w(e,void 0,void 0,l)))try{for(let i of readdirSync(e,{withFileTypes:!0})){let g=join(e,i.name);if(i.isSymbolicLink())if(r)g=realpathSync(g);else if(s&&w(g,t,f,l))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:g};else continue;i.isSymbolicLink()||i.isDirectory()?yield*P(g,{extensions:t,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:s,match:f,maxDepth:c-1,skip:l}):i.isFile()&&n&&w(g,t,f,l)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:g});}}catch(i){throw i instanceof a$1?i:new a$1(i,e)}}var Re=(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},o=[];for(let n of P(e,r))o.push(n.path);return o},Se=Re;var S=0,k=4,be=2,he=1,D=Symbol("findUpStop");var ve=async(e,t)=>{if(y(e),!existsSync(e)){await mkdir(e,{recursive:!0});return}for await(let r of await readdir(e))await rm(join(a(e),r),{...t,force:!0,recursive:!0});},Te=ve;var Ye=(e,t)=>{if(y(e),!existsSync(e)){mkdirSync(e,{recursive:!0});return}for(let r of readdirSync(e))rmSync(join(a(e),r),{...t,force:!0,recursive:!0});},We=Ye;var C=/\r?\n/g,N=`
12
12
  `,W=`\r
13
- `,_t=platform==="win32"?W:N,Nt=t=>{let e=t.match(C);if(!e||e.length===0)return null;let r=e.filter(n=>n===W).length,o=e.length-r;return r>o?W:N},Vt=(t,e)=>t.replaceAll(C,e);var Mt=async(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=e.cwd?a(e.cwd):process.cwd();u(r);let o=resolve(r),{root:n}=parse(o),s=a(e.stopAt??n);u(s);let a$1=resolve(o,s),c=e.type??"file",y=async function(f){return typeof t=="function"?[await t(f)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};for(;o&&o!==a$1&&o!==n;){for await(let f of await y(o)){if(f===T)return;if(f===void 0)continue;let m=isAbsolute(f)?f:resolve(o,f);try{let i=await stat(m);if(c==="file"&&i.isFile()||c==="directory"&&i.isDirectory())return m}catch{}}o=dirname(o);}},Bt=Mt;var qt=(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=e.cwd?a(e.cwd):process.cwd();u(r);let o=resolve(r),{root:n}=parse(o),s=a(e.stopAt??n);u(s);let a$1=resolve(o,s),c=e.type??"file",y=function(f){return typeof t=="function"?[t(f)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};for(;o&&o!==a$1&&o!==n;){for(let f of y(o)){if(f===T)return;if(f===void 0)continue;let m=isAbsolute(f)?f:resolve(o,f);try{let i=statSync(m);if(c==="file"&&i.isFile()||c==="directory"&&i.isDirectory())return m}catch{}}o=dirname(o);}},Qt=qt;async function te(t,e=0){u(t),t=a(t);try{return await access(t,e),!0}catch{return !1}}var O=te;function re(t,e=0){u(t),t=a(t);try{return accessSync(t,e),!0}catch{return !1}}var R=re;var se={brotli:brotliDecompress,gzip:unzip,none:(t,e)=>{e(null,t);}},ae=async(t,e)=>{if(u(t),t=a(t),!await O(t))throw new b$1(`unable to read the non-accessible file: ${t}`);if(!await O(t,4))throw new Error(`Unable to read the non-readable file: ${t}`);let{buffer:r,compression:o,encoding:n,flag:s}=e??{};return await readFile(t,s?{encoding:n,flag:s}:{encoding:n}).then(async a=>await new Promise((c,y)=>{se[o??"none"](a,(f,m)=>{f?y(f):c(r?m:m.toString());});})).catch(a=>{throw a})},E=ae;var pe={brotli:brotliDecompressSync,gzip:unzipSync,none:t=>t},le=(t,e)=>{if(u(t),t=a(t),!R(t))throw new b$1(`unable to read the non-accessible file: ${t}`);if(!R(t,4))throw new b$1(`invalid access to read file at: ${t}`);let{buffer:r,compression:o,encoding:n,flag:s}=e??{},a$1=readFileSync(t,s?{encoding:n,flag:s}:{encoding:n}),c=pe[o??"none"](a$1);return r?c:c.toString()},L=le;async function de(t,e,r){typeof e=="object"&&(r=e,e=void 0);let o=await E(t,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(o),{beforeParse:s,color:a$1}=r??{};return typeof s=="function"&&(n=s(n)),b$2(n,e,a(t),{color:a$1})}var ye=de;function ue(t,e,r){typeof e=="object"&&(r=e,e=void 0);let o=L(t,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(o),{beforeParse:s,color:a$1}=r??{};return typeof s=="function"&&(n=s(n)),b$2(n,e,a(t),{color:a$1})}var ge=ue;async function we(t,e,r){let{buffer:o,compression:n,encoding:s="utf8",flag:a,...c}=r??{},y=await E(t,{buffer:o,compression:n,encoding:s,flag:a});return typeof e=="function"?parse$1(y,e,c):parse$1(y,c)}var Oe=we;function Re(t,e,r){let{buffer:o,compression:n,encoding:s="utf8",flag:a,...c}=r??{},y=L(t,{buffer:o,compression:n,encoding:s,flag:a});return typeof e=="function"?parse$1(y,e,c):parse$1(y,c)}var Se=Re;var he=t=>{if(typeof t!="string"&&!(t instanceof ArrayBuffer)&&!ArrayBuffer.isView(t))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},I=he;var be=new TextEncoder,Fe=t=>{if(t instanceof Uint8Array)return t;if(typeof t=="string")return be.encode(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t)){let e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return new Uint8Array(e)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},_=Fe;var De=async(t,e,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},u(t),I(e),t=a(t);try{let o=await O(t,0);if(!o&&r.recursive){let a=dirname(t);await O(a,0)||await mkdir(a,{recursive:!0});}let n;await writeFile(`${t}.tmp`,_(e),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(n=await stat(t),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),await rename(t,`${t}.bak`));let s=`${t}.tmp`;if(r.chown)try{await chown(s,r.chown.uid,r.chown.gid);}catch{}await chmod(s,n&&!r.mode?n.mode:r.mode??438),await rename(s,t);}catch(o){throw new Error(`Failed to write file at: ${t} - ${o.message}`,{cause:o})}finally{await O(`${t}.tmp`)&&await unlink(`${t}.tmp`);}},U=De;var Ne=(t,e,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},u(t),I(e),t=a(t);try{let o=R(t,0);if(!o&&r.recursive){let a=dirname(t);R(a,0)||mkdirSync(a,{recursive:!0});}let n;writeFileSync(`${t}.tmp`,_(e),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(n=statSync(t),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),renameSync(t,`${t}.bak`));let s=`${t}.tmp`;if(r.chown)try{chownSync(s,r.chown.uid,r.chown.gid);}catch{}chmodSync(s,n&&!r.mode?n.mode:r.mode??438),renameSync(s,t);}catch(o){throw new Error(`Failed to write file at: ${t} - ${o.message}`,{cause:o})}finally{R(`${t}.tmp`)&&unlinkSync(`${t}.tmp`);}},D=Ne;var Ve=/^(?:( )+|\t+)/,v="space",X="tab";function j(t,e){let r=new Map,o=0,n,s;for(let a of t.split(/\n/g)){if(!a)continue;let c,y,f,m,i,g=a.match(Ve);if(g===null)o=0,n="";else {if(c=g[0].length,y=g[1]?v:X,e&&y===v&&c===1)continue;y!==n&&(o=0),n=y,f=1,m=0;let J=c-o;if(o=c,J===0)f=0,m=1;else {let q=J>0?J:-J;s=$e(y,q);}i=r.get(s),i=i===void 0?[1,0]:[i[0]+f,i[1]+m],r.set(s,i);}}return r}function $e(t,e){return (t===v?"s":"t")+String(e)}function Ce(t){let r=t[0]==="s"?v:X,o=Number(t.slice(1));return {type:r,amount:o}}function ze(t){let e,r=0,o=0;for(let[n,[s,a]]of t)(s>r||s===r&&a>o)&&(r=s,o=a,e=n);return e}function Ke(t,e){return (t===v?" ":" ").repeat(e)}function A(t){if(typeof t!="string")throw new TypeError("Expected a string");let e=j(t,!0);e.size===0&&(e=j(t,!1));let r=ze(e),o,n=0,s="";return r!==void 0&&({type:o,amount:n}=Ce(r),s=Ke(o,n)),{amount:n,type:o,indent:s}}var Be=async(t,e,r={})=>{let{detectIndent:o,indent:n,replacer:s,stringify:a=JSON.stringify,...c}={indent:" ",...r},y=n,f=`
14
- `;if(await O(t,4))try{let i=await readFile(t,"utf8");if(o){let{indent:g}=A(i);y=g;}f=i.endsWith(`
13
+ `,_e=platform==="win32"?W:N,Ne=e=>{let t=e.match(C);if(!t||t.length===0)return null;let r=t.filter(n=>n===W).length,o=t.length-r;return r>o?W:N},Ve=(e,t)=>e.replaceAll(C,t);var Me=async(e,t={})=>{if(typeof e!="string"&&!Array.isArray(e)&&typeof e!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=t.cwd?a(t.cwd):process.cwd();y(r);let o=resolve(r),{root:n}=parse(o),s=a(t.stopAt??n);y(s);let a$1=resolve(o,s),c=t.type??"file",u=async function(f){return typeof e=="function"?[await e(f)]:typeof e=="string"?[e]:Array.isArray(e)?e:[e]};for(;o&&o!==a$1&&o!==n;){for await(let f of await u(o)){if(f===D)return;if(f===void 0)continue;let l=isAbsolute(f)?f:resolve(o,f);try{let i=await stat(l);if(c==="file"&&i.isFile()||c==="directory"&&i.isDirectory())return l}catch{}}o=dirname(o);}},Be=Me;var qe=(e,t={})=>{if(typeof e!="string"&&!Array.isArray(e)&&typeof e!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=t.cwd?a(t.cwd):process.cwd();y(r);let o=resolve(r),{root:n}=parse(o),s=a(t.stopAt??n);y(s);let a$1=resolve(o,s),c=t.type??"file",u=function(f){return typeof e=="function"?[e(f)]:typeof e=="string"?[e]:Array.isArray(e)?e:[e]};for(;o&&o!==a$1&&o!==n;){for(let f of u(o)){if(f===D)return;if(f===void 0)continue;let l=isAbsolute(f)?f:resolve(o,f);try{let i=statSync(l);if(c==="file"&&i.isFile()||c==="directory"&&i.isDirectory())return l}catch{}}o=dirname(o);}},Qe=qe;async function et(e,t=0){y(e),e=a(e);try{return await access(e,t),!0}catch{return !1}}var O=et;function rt(e,t=0){y(e),e=a(e);try{return accessSync(e,t),!0}catch{return !1}}var R=rt;var st={brotli:brotliDecompress,gzip:unzip,none:(e,t)=>{t(null,e);}},at=async(e,t)=>{if(y(e),e=a(e),!await O(e))throw new b(`unable to read the non-accessible file: ${e}`);if(!await O(e,4))throw new Error(`Unable to read the non-readable file: ${e}`);let{buffer:r,compression:o,encoding:n,flag:s}=t??{};return await readFile(e,s?{encoding:n,flag:s}:{encoding:n}).then(async a=>await new Promise((c,u)=>{st[o??"none"](a,(f,l)=>{f?u(f):c(r?l:l.toString());});})).catch(a=>{throw a})},v=at;var pt={brotli:brotliDecompressSync,gzip:unzipSync,none:e=>e},lt=(e,t)=>{if(y(e),e=a(e),!R(e))throw new b(`unable to read the non-accessible file: ${e}`);if(!R(e,4))throw new b(`invalid access to read file at: ${e}`);let{buffer:r,compression:o,encoding:n,flag:s}=t??{},a$1=readFileSync(e,s?{encoding:n,flag:s}:{encoding:n}),c=pt[o??"none"](a$1);return r?c:c.toString()},T=lt;async function dt(e,t,r){typeof t=="object"&&(r=t,t=void 0);let o=await v(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(o),{beforeParse:s,color:a$1}=r??{};return typeof s=="function"&&(n=s(n)),b$1(n,t,a(e),{color:a$1})}var yt=dt;function ut(e,t,r){typeof t=="object"&&(r=t,t=void 0);let o=T(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(o),{beforeParse:s,color:a$1}=r??{};return typeof s=="function"&&(n=s(n)),b$1(n,t,a(e),{color:a$1})}var gt=ut;async function wt(e,t,r){let{buffer:o,compression:n,encoding:s="utf8",flag:a,...c}=r??{},u=await v(e,{buffer:o,compression:n,encoding:s,flag:a});return typeof t=="function"?parse$1(u,t,c):parse$1(u,c)}var Ot=wt;function Rt(e,t,r){let{buffer:o,compression:n,encoding:s="utf8",flag:a,...c}=r??{},u=T(e,{buffer:o,compression:n,encoding:s,flag:a});return typeof t=="function"?parse$1(u,t,c):parse$1(u,c)}var St=Rt;var Ft=async(e,t={})=>{y(e);try{await unlink(e);}catch{}try{await rm(e,{force:!0,maxRetries:t?.maxRetries,recursive:!0,retryDelay:t?.retryDelay});}catch{}},xt=Ft;var Dt=(e,t={})=>{y(e);try{unlinkSync(e);}catch{}try{rmSync(e,{force:!0,maxRetries:t?.maxRetries,recursive:!0,retryDelay:t?.retryDelay});}catch{}},vt=Dt;var Tt=e=>{if(typeof e!="string"&&!(e instanceof ArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},I=Tt;var Et=new TextEncoder,Lt=e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return Et.encode(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e)){let t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},_=Lt;var Nt=async(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},y(e),I(t),e=a(e);try{let o=await O(e,0);if(!o&&r.recursive){let a=dirname(e);await O(a,0)||await mkdir(a,{recursive:!0});}let n;await writeFile(`${e}.tmp`,_(t),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(n=await stat(e),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),await rename(e,`${e}.bak`));let s=`${e}.tmp`;if(r.chown)try{await chown(s,r.chown.uid,r.chown.gid);}catch{}await chmod(s,n&&!r.mode?n.mode:r.mode??438),await rename(s,e);}catch(o){throw new Error(`Failed to write file at: ${e} - ${o.message}`,{cause:o})}finally{await O(`${e}.tmp`)&&await unlink(`${e}.tmp`);}},E=Nt;var jt=(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},y(e),I(t),e=a(e);try{let o=R(e,0);if(!o&&r.recursive){let a=dirname(e);R(a,0)||mkdirSync(a,{recursive:!0});}let n;writeFileSync(`${e}.tmp`,_(t),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(n=statSync(e),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),renameSync(e,`${e}.bak`));let s=`${e}.tmp`;if(r.chown)try{chownSync(s,r.chown.uid,r.chown.gid);}catch{}chmodSync(s,n&&!r.mode?n.mode:r.mode??438),renameSync(s,e);}catch(o){throw new Error(`Failed to write file at: ${e} - ${o.message}`,{cause:o})}finally{R(`${e}.tmp`)&&unlinkSync(`${e}.tmp`);}},L=jt;var Xt=/^(?:( )+|\t+)/,U="space",X="tab";function j(e,t){let r=new Map,o=0,n,s;for(let a of e.split(/\n/g)){if(!a)continue;let c,u,f,l,i,g=a.match(Xt);if(g===null)o=0,n="";else {if(c=g[0].length,u=g[1]?U:X,t&&u===U&&c===1)continue;u!==n&&(o=0),n=u,f=1,l=0;let J=c-o;if(o=c,J===0)f=0,l=1;else {let q=J>0?J:-J;s=Ht(u,q);}i=r.get(s),i=i===void 0?[1,0]:[i[0]+f,i[1]+l],r.set(s,i);}}return r}function Ht(e,t){return (e===U?"s":"t")+String(t)}function Gt(e){let r=e[0]==="s"?U:X,o=Number(e.slice(1));return {type:r,amount:o}}function qt(e){let t,r=0,o=0;for(let[n,[s,a]]of e)(s>r||s===r&&a>o)&&(r=s,o=a,t=n);return t}function Qt(e,t){return (e===U?" ":" ").repeat(t)}function A(e){if(typeof e!="string")throw new TypeError("Expected a string");let t=j(e,!0);t.size===0&&(t=j(e,!1));let r=qt(t),o,n=0,s="";return r!==void 0&&({type:o,amount:n}=Gt(r),s=Qt(o,n)),{amount:n,type:o,indent:s}}var er=async(e,t,r={})=>{let{detectIndent:o,indent:n,replacer:s,stringify:a=JSON.stringify,...c}={indent:" ",...r},u=n,f=`
14
+ `;if(await O(e,4))try{let i=await readFile(e,"utf8");if(o){let{indent:g}=A(i);u=g;}f=i.endsWith(`
15
15
  `)?`
16
- `:"";}catch(i){if(i.code!=="ENOENT")throw i}let m=a(e,s,y);await U(t,`${m}${f}`,c);},je=Be;var He=(t,e,r={})=>{let{detectIndent:o,indent:n,replacer:s,stringify:a=JSON.stringify,...c}={indent:" ",...r},y=n,f=`
17
- `;if(R(t,4))try{let i=readFileSync(t,"utf8");if(o){let{indent:g}=A(i);y=g;}f=i.endsWith(`
16
+ `:"";}catch(i){if(i.code!=="ENOENT")throw i}let l=a(t,s,u);await E(e,`${l}${f}`,c);},tr=er;var or=(e,t,r={})=>{let{detectIndent:o,indent:n,replacer:s,stringify:a=JSON.stringify,...c}={indent:" ",...r},u=n,f=`
17
+ `;if(R(e,4))try{let i=readFileSync(e,"utf8");if(o){let{indent:g}=A(i);u=g;}f=i.endsWith(`
18
18
  `)?`
19
- `:"";}catch(i){if(i.code!=="ENOENT")throw i}let m=a(e,s,y);D(t,`${m}${f}`,c);},Ge=He;async function qe(t,e,r,o){let n=typeof r=="function"||Array.isArray(r)?stringify(e,r,o):stringify(e,r);await U(t,n);}var Qe=qe;function Ze(t,e,r,o){let n=typeof r=="function"||Array.isArray(r)?stringify(e,r,o):stringify(e,r);D(t,n);}var tr=Ze;
19
+ `:"";}catch(i){if(i.code!=="ENOENT")throw i}let l=a(t,s,u);L(e,`${l}${f}`,c);},ir=or;async function nr(e,t,r,o){let n=typeof r=="function"||Array.isArray(r)?stringify(t,r,o):stringify(t,r);await E(e,n);}var sr=nr;function ar(e,t,r,o){let n=typeof r=="function"||Array.isArray(r)?stringify(t,r,o):stringify(t,r);L(e,n);}var fr=ar;
20
20
 
21
- export { W as CRLF, _t as EOL, T as FIND_UP_STOP, S as F_OK, N as LF, k as R_OK, ht as W_OK, bt as X_OK, mt as collect, St as collectSync, Nt as detect, Lt as emptyDir, Wt as emptyDirSync, Bt as findUp, Qt as findUpSync, Vt as format, O as isAccessible, R as isAccessibleSync, E as readFile, L as readFileSync, ye as readJson, ge as readJsonSync, Oe as readYaml, Se as readYamlSync, x as walk, P as walkSync, U as writeFile, D as writeFileSync, je as writeJson, Ge as writeJsonSync, Qe as writeYaml, tr as writeYamlSync };
21
+ export { W as CRLF, _e as EOL, D as FIND_UP_STOP, S as F_OK, N as LF, k as R_OK, be as W_OK, he as X_OK, me as collect, Se as collectSync, Ne as detect, Te as emptyDir, We as emptyDirSync, Be as findUp, Qe as findUpSync, Ve as format, O as isAccessible, R as isAccessibleSync, v as readFile, T as readFileSync, yt as readJson, gt as readJsonSync, Ot as readYaml, St as readYamlSync, xt as remove, vt as removeSync, x as walk, P as walkSync, E as writeFile, L as writeFileSync, tr as writeJson, ir as writeJsonSync, sr as writeYaml, fr as writeYamlSync };
22
22
  //# sourceMappingURL=out.js.map
23
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/walk.ts","../src/utils/assert-valid-file-or-directory-path.ts","../src/utils/glob-to-regex.ts","../src/utils/walk-include.ts","../src/collect.ts","../src/walk-sync.ts","../src/collect-sync.ts","../src/constants.ts","../src/empty-dir.ts","../src/empty-dir-sync.ts","../src/eol.ts","../src/find-up.ts","../src/find-up-sync.ts","../src/is-accessible.ts","../src/is-accessible-sync.ts","../src/read-file.ts","../src/read-file-sync.ts","../src/read-json.ts","../src/read-json-sync.ts","../src/read-yaml.ts","../src/read-yaml-sync.ts","../src/write-file.ts","../src/utils/assert-valid-file-contents.ts","../src/utils/to-uint-8-array.ts","../src/write-file-sync.ts","../src/write-json.ts","../../../node_modules/.pnpm/detect-indent@7.0.1/node_modules/detect-indent/index.js","../src/write-json-sync.ts","../src/write-yaml.ts","../src/write-yaml-sync.ts"],"names":["readdir","realpath","stat","basename","join","normalize","resolve","assertValidFileOrDirectoryPath","fileOrDirectoryPath","assert_valid_file_or_directory_path_default","globToRegExp","glob","reString","glob_to_regex_default","walkInclude","path","extensions","match","skip","extension","pattern","walk_include_default","_createWalkEntry","normalizePath","name","info","walk","directory","followSymlinks","includeDirectories","includeFiles","includeSymlinks","maxDepth","mappedMatch","mappedSkip","to_path_default","entry","error","walk_error_default","collect","options","config","entries","collect_default","readdirSync","realpathSync","statSync","walkSync","collectSync","collect_sync_default","F_OK","R_OK","W_OK","X_OK","FIND_UP_STOP","existsSync","mkdir","rm","emptyDir","dir","item","empty_dir_default","mkdirSync","rmSync","empty_dir_sync_default","platform","regDetect","LF","CRLF","EOL","detect","content","d","crlf","newline","lf","format","eol","dirname","isAbsolute","parse","findUp","cwd","root","stopPath","stopAt","type","getMatchers","currentDirectory","fileName","filePath","stats","find_up_default","findUpSync","find_up_sync_default","access","isAccessible","mode","is_accessible_default","accessSync","isAccessibleSync","is_accessible_sync_default","nodeReadFile","brotliDecompress","unzip","decompressionMethods","buffer","callback","readFile","permission_error_default","compression","encoding","flag","reject","result","read_file_default","nodeReadFileSync","brotliDecompressSync","unzipSync","readFileSync","decompressed","read_file_sync_default","readJson","reviver","data","beforeParse","color","parse_json_default","read_json_default","readJsonSync","read_json_sync_default","readYaml","parseOptions","read_yaml_default","readYamlSync","read_yaml_sync_default","chmod","chown","rename","nodeStat","unlink","nodeWriteFile","assertValidFileContents","contents","assert_valid_file_contents_default","encoder","toUint8Array","bytes","to_uint_8_array_default","writeFile","pathExists","temporaryPath","write_file_default","chmodSync","chownSync","renameSync","unlinkSync","nodeWriteFileSync","writeFileSync","write_file_sync_default","INDENT_REGEX","INDENT_TYPE_SPACE","INDENT_TYPE_TAB","makeIndentsMap","string","ignoreSingleSpaces","indents","previousSize","previousIndentType","key","line","indent","indentType","use","weight","matches","indentDifference","absoluteIndentDifference","encodeIndentsKey","indentAmount","decodeIndentsKey","indentsKey","amount","getMostUsedKey","maxUsed","maxWeight","usedCount","makeIndentString","detectIndent","keyOfMostUsedIndent","writeJson","indentOption","replacer","stringify","writeOptions","trailingNewline","file","dIndent","json","write_json_default","writeJsonSync","write_json_sync_default","writeYaml","write_yaml_default","writeYamlSync","write_yaml_sync_default"],"mappings":"0HAMA,OAAS,WAAAA,GAAS,YAAAC,GAAU,QAAAC,OAAY,mBACxC,OAAS,YAAAC,GAAU,QAAAC,GAAM,aAAAC,GAAW,WAAAC,OAAe,YCNnD,IAAMC,EAAkCC,GAAmC,CACvE,GAAI,CAACA,GAAwB,EAAEA,aAA+B,MAAQ,OAAOA,GAAwB,SACjG,MAAM,IAAI,UAAU,yCAAyC,CAErE,EAEOC,EAAQF,ECPf,IAAMG,EAAgBC,GAAyB,CAC3C,IAAMC,EAAWD,EAEZ,QAAQ,QAAS,UAAU,EAE3B,QAAQ,QAAS,MAAM,EAEvB,QAAQ,mBAAoB,SAAS,EAErC,QAAQ,MAAO,MAAM,EAErB,QAAQ,YAAa,KAAK,EAE1B,QAAQ,MAAO,GAAG,EAElB,QAAQ,MAAO,GAAG,EAElB,QAAQ,KAAM,GAAG,EAEjB,QAAQ,cAAe,OAAO,EAGnC,OAAO,IAAI,OAAO,I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AAW,GAAGC,CAAa,EAAI,CAAE,OAAQ,IAAM,GAAG1J,CAAQ,EAE7HmI,EAASoB,EACTI,EAAkB;AAAA,EAEtB,GAAI9F,EAAiBtF,EAAM,CAAI,EAC3B,GAAI,CAEA,IAAMqL,EAAO7E,GAAaxG,EAAM,MAAM,EAEtC,GAAI6K,EAAc,CAEd,GAAM,CAAE,OAAQS,CAAQ,EAAIT,EAAeQ,CAAI,EAE/CzB,EAAS0B,CACb,CAEAF,EAAkBC,EAAK,SAAS;AAAA,CAAI,EAAI;AAAA,EAAO,EAEnD,OAAS/J,EAAY,CAEjB,GAAIA,EAAM,OAAS,SACf,MAAMA,CAEd,CAIJ,IAAMiK,EAAOL,EAAUrE,EAAMoE,EAAUrB,CAAM,EAE7CZ,EAAchJ,EAAM,GAAGuL,CAAI,GAAGH,CAAe,GAAID,CAAY,CACjE,EAEOO,GAAQD,GC3Cf,OAAS,aAAAP,MAAiB,OAuB1B,eAAeS,GACX3L,EAEA6G,EAEAoE,EAEAxJ,EACa,CAEb,IAAM+B,EAAU,OAAOyH,GAAa,YAAc,MAAM,QAAQA,CAAQ,EAAIC,EAAUrE,EAAMoE,EAAUxJ,CAAO,EAAIyJ,EAAUrE,EAAMoE,CAAwB,EAGzJ,MAAMxC,EAAUzI,EAAMwD,CAAO,CACjC,CAEA,IAAOoI,GAAQD,GCvCf,OAAS,aAAAT,MAAiB,OAuB1B,SAASW,GACL7L,EAEA6G,EAEAoE,EAEAxJ,EACI,CAEJ,IAAM+B,EAAU,OAAOyH,GAAa,YAAc,MAAM,QAAQA,CAAQ,EAAIC,EAAUrE,EAAMoE,EAAUxJ,CAAO,EAAIyJ,EAAUrE,EAAMoE,CAAwB,EAGzJjC,EAAchJ,EAAMwD,CAAO,CAC/B,CAEA,IAAOsI,GAAQD","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdir, realpath, stat } from \"node:fs/promises\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = async (path: string): Promise<WalkEntry> => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = await stat(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/**\n * Walks the file tree rooted at root, yielding each file or directory in the\n * tree filtered according to the given options.\n * Options:\n * - maxDepth?: number = Infinity;\n * - includeFiles?: boolean = true;\n * - includeDirs?: boolean = true;\n * - includeSymlinks?: boolean = true;\n * - followSymlinks?: boolean = false;\n * - extensions?: string[];\n * - match?: string | ReadonlyArray<string>;\n * - skip?: string | ReadonlyArray<string>;\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default async function* walk(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): AsyncIterableIterator<WalkEntry> {\n assertValidFileOrDirectoryPath(directory);\n\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield await _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,security/detect-non-literal-fs-filename,no-loops/no-loops\n for await (const entry of await readdir(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = await realpath(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walk(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileOrDirectoryPath = (fileOrDirectoryPath: any): void => {\n if (!fileOrDirectoryPath || (!(fileOrDirectoryPath instanceof URL) && typeof fileOrDirectoryPath !== \"string\")) {\n throw new TypeError(\"Path must be a non-empty string or URL.\");\n }\n};\n\nexport default assertValidFileOrDirectoryPath;\n","const globToRegExp = (glob: string): RegExp => {\n const reString = glob\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.\\*/g, \".([^/]*)\") // Replace .* with .([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\*\\*/g, \"(.*)\") // Replace ** with (.*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/(?<!\\.)\\*(?!\\*)/g, \"([^/]*)\") // Replace * (not preceded by . or followed by *) with ([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\?/g, \"[^/]\") // Replace ? with [^/]\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.(?!\\*)/g, \"\\\\.\") // Escape . that is not preceded by *\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\{/g, \"(\") // Replace { with (\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\}/g, \")\") // Replace } with )\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/,/g, \"|\") // Replace , with |\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\[!(.*?)\\]/g, \"[^$1]\"); // Replace [!number-number] with [^number-number]\n\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp,security/detect-non-literal-regexp\n return new RegExp(`^${reString}$`);\n};\n\nexport default globToRegExp;\n","const walkInclude = (path: string, extensions?: string[], match?: RegExp[], skip?: RegExp[]): boolean => {\n if (extensions && !extensions.some((extension): boolean => path.endsWith(extension))) {\n return false;\n }\n\n if (match && !match.some((pattern): boolean => pattern.test(path))) {\n return false;\n }\n\n return !(skip && skip.some((pattern): boolean => pattern.test(path)));\n};\n\nexport default walkInclude;\n","import type { WalkOptions } from \"./types\";\nimport walk from \"./walk\";\n\nconst collect = async (directory: string, options: WalkOptions = {}): Promise<string[]> => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for await (const entry of walk(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collect;\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n/** Create {@linkcode WalkEntry} for the `path` synchronously. */\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = (path: string): WalkEntry => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = statSync(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/** Same as {@linkcode walk} but uses synchronous ops */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default function* walkSync(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): IterableIterator<WalkEntry> {\n assertValidFileOrDirectoryPath(directory);\n\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops,security/detect-non-literal-fs-filename\n for (const entry of readdirSync(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = realpathSync(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walkSync(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","import type { WalkOptions } from \"./types\";\nimport walkSync from \"./walk-sync\";\n\nconst collectSync = (directory: string, options: WalkOptions = {}): string[] => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const entry of walkSync(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collectSync;\n","/** Is the path visible to the calling process? */\nexport const F_OK = 0; // constants?.F_OK\n\n/** Is the path readable to the calling process? */\nexport const R_OK = 4; // constants?.R_OK\n\n/** Is the path writable to the calling process? */\nexport const W_OK = 2; // constants?.W_OK\n\n/** Is the path executable to the calling process? */\nexport const X_OK = 1; // constants?.X_OK\n\nexport const FIND_UP_STOP = Symbol(\"findUpStop\");\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport { existsSync } from \"node:fs\";\nimport { mkdir, readdir, rm } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nimport type { EmptyDirOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/**\n * Ensures that a directory is empty.\n * Deletes directory contents if the directory is not empty.\n * If the directory does not exist, it is created.\n * The directory itself is not deleted.\n */\n// eslint-disable-next-line unicorn/prevent-abbreviations\nconst emptyDir = async (dir: URL | string, options?: EmptyDirOptions): Promise<void> => {\n assertValidFileOrDirectoryPath(dir);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(dir)) {\n // if not exist. then create it\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await mkdir(dir, { recursive: true });\n\n return;\n }\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax,security/detect-non-literal-fs-filename\n for await (const item of await readdir(dir)) {\n await rm(join(toPath(dir), item), { ...options, force: true, recursive: true });\n }\n}\n\nexport default emptyDir;\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport { existsSync, mkdirSync, readdirSync, rmSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nimport type { EmptyDirOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/**\n * Ensures that a directory is empty.\n * Deletes directory contents if the directory is not empty.\n * If the directory does not exist, it is created.\n * The directory itself is not deleted.\n */\n// eslint-disable-next-line unicorn/prevent-abbreviations\nconst emptyDir = (dir: URL | string, options?: EmptyDirOptions): void => {\n assertValidFileOrDirectoryPath(dir);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(dir)) {\n // if not exist. then create it\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(dir, { recursive: true });\n\n return;\n }\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax,security/detect-non-literal-fs-filename\n for (const item of readdirSync(dir)) {\n rmSync(join(toPath(dir), item), { ...options, force: true, recursive: true });\n }\n}\n\nexport default emptyDir;\n","import { platform } from \"node:process\";\n\nconst regDetect = /\\r?\\n/g;\n\n/** End-of-line character for POSIX platforms such as macOS and Linux. */\nexport const LF = \"\\n\" as const;\n\n/** End-of-line character for Windows platforms. */\nexport const CRLF = \"\\r\\n\" as const;\n\n/**\n * End-of-line character evaluated for the current platform.\n */\nexport const EOL: \"\\n\" | \"\\r\\n\" = platform === \"win32\" ? CRLF : LF;\n\n/**\n * Detect the EOL character for string input.\n * Returns null if no newline.\n */\nexport const detect = (content: string): typeof EOL | null => {\n const d = content.match(regDetect);\n\n if (!d || d.length === 0) {\n return null;\n }\n\n const crlf = d.filter((newline) => newline === CRLF).length;\n const lf = d.length - crlf;\n\n return crlf > lf ? CRLF : LF;\n};\n\n/**\n * Format the file to the targeted EOL.\n */\nexport const format = (content: string, eol: typeof EOL): string => content.replaceAll(regDetect, eol);\n","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, parse, resolve } from \"node:path\";\n\nimport { FIND_UP_STOP } from \"./constants\";\nimport type { FindUpOptions, Match } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: ReadonlyArray<string> | string[] | string | ((directory: string) => Match | Promise<Match>),\n options: FindUpOptions = {},\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): Promise<string | undefined> => {\n if (typeof name !== \"string\" && !Array.isArray(name) && typeof name !== \"function\") {\n throw new TypeError(\"The `name` argument must be of type `string` or `string[]`\");\n }\n\n const cwd = options.cwd ? toPath(options.cwd) : process.cwd();\n\n assertValidFileOrDirectoryPath(cwd);\n\n let directory = resolve(cwd);\n\n const { root } = parse(directory);\n const stopPath = toPath(options.stopAt ?? root);\n\n assertValidFileOrDirectoryPath(stopPath);\n\n const stopAt = resolve(directory, stopPath);\n const type = options.type ?? \"file\";\n\n const getMatchers = async function (currentDirectory: string): Promise<(string | typeof FIND_UP_STOP | undefined)[]> {\n if (typeof name === \"function\") {\n const match = await name(currentDirectory);\n\n return [match];\n }\n\n if (typeof name === \"string\") {\n return [name];\n }\n\n if (Array.isArray(name)) {\n return name as string[];\n }\n\n return [name];\n };\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n // eslint-disable-next-line no-await-in-loop,no-loops/no-loops,no-restricted-syntax\n for await (const fileName of await getMatchers(directory)) {\n if (fileName === FIND_UP_STOP) {\n return undefined;\n }\n\n if (fileName === undefined) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = await stat(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUp;\n","import { statSync } from \"node:fs\";\nimport { dirname, isAbsolute, parse, resolve } from \"node:path\";\n\nimport { FIND_UP_STOP } from \"./constants\";\nimport type { FindUpOptions, Match } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: ReadonlyArray<string> | string[] | string | ((directory: string) => Match),\n options: FindUpOptions = {},\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): string | undefined => {\n if (typeof name !== \"string\" && !Array.isArray(name) && typeof name !== \"function\") {\n throw new TypeError(\"The `name` argument must be of type `string` or `string[]`\");\n }\n\n const cwd = options.cwd ? toPath(options.cwd) : process.cwd();\n\n assertValidFileOrDirectoryPath(cwd);\n\n let directory = resolve(cwd);\n\n const { root } = parse(directory);\n const stopPath = toPath(options.stopAt ?? root);\n\n assertValidFileOrDirectoryPath(stopPath);\n\n const stopAt = resolve(directory, stopPath);\n const type = options.type ?? \"file\";\n\n const getMatchers = function (currentDirectory: string): (string | typeof FIND_UP_STOP | undefined)[] {\n if (typeof name === \"function\") {\n const match = name(currentDirectory);\n\n return [match];\n }\n\n if (typeof name === \"string\") {\n return [name];\n }\n\n if (Array.isArray(name)) {\n return name as string[];\n }\n\n return [name];\n };\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const fileName of getMatchers(directory)) {\n if (fileName === FIND_UP_STOP) {\n return undefined;\n }\n\n if (fileName === undefined) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = statSync(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUpSync;\n","import { access } from \"node:fs/promises\";\n\nimport { F_OK } from \"./constants\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/** Returns a Promise that resolves to a boolean indicating if the path is accessible or not. */\nasync function isAccessible(path: URL | string, mode?: number): Promise<boolean>;\n// eslint-disable-next-line func-style\nasync function isAccessible(path: URL | string, mode: number = F_OK): Promise<boolean> {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n await access(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessible;\n","import { accessSync } from \"node:fs\";\n\nimport { F_OK } from \"./constants\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/** Returns a boolean indicating if the path is accessible or not. */\nfunction isAccessibleSync(path: URL | string, mode?: number): boolean;\n// eslint-disable-next-line func-style\nfunction isAccessibleSync(path: URL | string, mode: number = F_OK): boolean {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n accessSync(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessibleSync;\n","import { readFile as nodeReadFile } from \"node:fs/promises\";\nimport { brotliDecompress, unzip } from \"node:zlib\";\n\nimport { R_OK } from \"./constants\";\nimport PermissionError from \"./error/permission-error\";\nimport isAccessible from \"./is-accessible\";\nimport type { ContentType, ReadFileOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst decompressionMethods = {\n brotli: brotliDecompress,\n gzip: unzip,\n none: (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => {\n callback(null, buffer);\n },\n} as const;\n\nconst readFile = async <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: URL | string,\n options?: O,\n): Promise<ContentType<O>> => {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n if (!(await isAccessible(path))) {\n throw new PermissionError(`unable to read the non-accessible file: ${path}`);\n }\n\n if (!(await isAccessible(path, R_OK))) {\n throw new Error(`Unable to read the non-readable file: ${path}`);\n }\n\n const { buffer, compression, encoding, flag } = options ?? {};\n\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n return await nodeReadFile(path, flag ? { encoding, flag } : { encoding })\n .then(\n async (content) =>\n // eslint-disable-next-line compat/compat\n await new Promise<ContentType<O> | undefined>((resolve, reject) => {\n decompressionMethods[compression ?? \"none\"](content, (error, result) => {\n if (error) {\n reject(error);\n } else {\n resolve((buffer ? result : result.toString()) as ContentType<O>);\n }\n });\n }),\n )\n .catch((error: unknown) => {\n throw error;\n });\n};\n\nexport default readFile;\n","import { readFileSync as nodeReadFileSync } from \"node:fs\";\nimport { brotliDecompressSync, unzipSync } from \"node:zlib\";\n\nimport { R_OK } from \"./constants\";\nimport PermissionError from \"./error/permission-error\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { ContentType, ReadFileOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst decompressionMethods = {\n brotli: brotliDecompressSync,\n gzip: unzipSync,\n none: (buffer: Buffer) => buffer,\n} as const;\n\nconst readFileSync = <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: URL | string,\n options?: O,\n): ContentType<O> => {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n if (!isAccessibleSync(path)) {\n throw new PermissionError(`unable to read the non-accessible file: ${path}`);\n }\n\n if (!isAccessibleSync(path, R_OK)) {\n throw new PermissionError(`invalid access to read file at: ${path}`);\n }\n\n const { buffer, compression, encoding, flag } = options ?? {};\n\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const content = nodeReadFileSync(path, flag ? { encoding, flag } : { encoding });\n\n const decompressed = decompressionMethods[compression ?? \"none\"](content);\n\n return (buffer ? decompressed : decompressed.toString()) as ContentType<O>;\n};\n\nexport default readFileSync;\n","import type { JsonValue } from \"type-fest\";\n\nimport readFile from \"./read-file\";\nimport type { JsonReviver, ReadJsonOptions } from \"./types\";\nimport parseJson from \"./utils/parse-json\";\nimport toPath from \"./utils/to-path\";\n\nasync function readJson<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): Promise<T>;\n\nasync function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): Promise<T>;\n// eslint-disable-next-line func-style\nasync function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver | ReadJsonOptions, options?: ReadJsonOptions): Promise<T> {\n if (typeof reviver === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n const content = await readFile(path, {\n buffer: true,\n encoding: undefined,\n });\n\n // Unlike `buffer.toString()` and `fs.readFile(path, 'utf8')`, `TextDecoder` will remove BOM.\n let data = new TextDecoder().decode(content);\n\n const { beforeParse, color } = options ?? {};\n\n if (typeof beforeParse === \"function\") {\n data = beforeParse(data);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parseJson<T>(data, reviver, toPath(path), { color });\n}\n\nexport default readJson;\n","import type { JsonValue } from \"type-fest\";\n\nimport readFileSync from \"./read-file-sync\";\nimport type { JsonReviver, ReadJsonOptions } from \"./types\";\nimport parseJson from \"./utils/parse-json\";\nimport toPath from \"./utils/to-path\";\n\nfunction readJsonSync<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): T;\n\nfunction readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): T;\n// eslint-disable-next-line func-style\nfunction readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver | ReadJsonOptions, options?: ReadJsonOptions): T {\n if (typeof reviver === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n const content = readFileSync(path, {\n buffer: true,\n encoding: undefined,\n });\n\n // Unlike `buffer.toString()` and `fs.readFile(path, 'utf8')`, `TextDecoder` will remove BOM.\n let data = new TextDecoder().decode(content);\n\n const { beforeParse, color } = options ?? {};\n\n if (typeof beforeParse === \"function\") {\n data = beforeParse(data);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parseJson<T>(data, reviver, toPath(path), { color });\n}\n\nexport default readJsonSync;\n","import { parse } from \"yaml\";\n\nimport readFile from \"./read-file\";\nimport type { ReadYamlOptions, YamlReviver } from \"./types\";\n\nasync function readYaml<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">): Promise<R>;\nasync function readYaml<R = Record<string, unknown>>(\n path: URL | string,\n reviver?: YamlReviver,\n options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">,\n): Promise<R>;\n\n// eslint-disable-next-line func-style\nasync function readYaml<R = Record<string, unknown>>(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n reviver?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\"> | YamlReviver,\n options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">,\n): Promise<R> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const {\n buffer,\n compression,\n encoding = \"utf8\",\n flag,\n ...parseOptions\n } = options ?? {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const content = await readFile(path, { buffer, compression, encoding, flag });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n return (typeof reviver === \"function\" ? parse(content, reviver, parseOptions) : parse(content, parseOptions)) as R;\n}\n\nexport default readYaml;\n","import { parse } from \"yaml\";\n\nimport readFileSync from \"./read-file-sync\";\nimport type { ReadYamlOptions, YamlReviver } from \"./types\";\n\nfunction readYamlSync<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">): R;\nfunction readYamlSync<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">): R;\n// eslint-disable-next-line func-style\nfunction readYamlSync<R = Record<string, unknown>>(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n reviver?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\"> | YamlReviver,\n options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">,\n): R {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const {\n buffer,\n compression,\n encoding = \"utf8\",\n flag,\n ...parseOptions\n } = options ?? {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const content = readFileSync(path, { buffer, compression, encoding, flag });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n return (typeof reviver === \"function\" ? parse(content, reviver, parseOptions) : parse(content, parseOptions)) as R;\n}\n\nexport default readYamlSync;\n","import type { Stats } from \"node:fs\";\nimport { chmod, chown, mkdir, rename, stat as nodeStat, unlink, writeFile as nodeWriteFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nimport { F_OK } from \"./constants\";\nimport isAccessible from \"./is-accessible\";\nimport type { WriteFileOptions } from \"./types\";\nimport assertValidFileContents from \"./utils/assert-valid-file-contents\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\nimport toUint8Array from \"./utils/to-uint-8-array\";\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeFile = async (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions): Promise<void> => {\n // eslint-disable-next-line no-param-reassign\n options = {\n encoding: \"utf8\",\n flag: \"w\",\n overwrite: true,\n recursive: true,\n ...options,\n };\n\n assertValidFileOrDirectoryPath(path);\n assertValidFileContents(content);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n const pathExists = await isAccessible(path, F_OK);\n\n if (!pathExists && options.recursive) {\n const directory = dirname(path);\n\n if (!(await isAccessible(directory, F_OK))) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await mkdir(directory, { recursive: true });\n }\n }\n\n let stat: Stats | undefined;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await nodeWriteFile(`${path}.tmp`, toUint8Array(content), { encoding: options.encoding, flag: options.flag });\n\n if (pathExists && !options.overwrite) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n stat = await nodeStat(path);\n\n if (options.chown === undefined) {\n // eslint-disable-next-line no-param-reassign\n options.chown = { gid: stat.gid, uid: stat.uid };\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await rename(path, `${path}.bak`);\n }\n\n const temporaryPath = `${path}.tmp`;\n\n if (options.chown) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await chown(temporaryPath, options.chown.uid, options.chown.gid);\n } catch {\n // On linux permissionless filesystems like exfat and fat32 the entire filesystem is normally owned by root,\n // and trying to chown it causes as permissions error.\n }\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await chmod(temporaryPath, stat && !options.mode ? stat.mode : options.mode ?? 0o666);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await rename(temporaryPath, path);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });\n } finally {\n if (await isAccessible(`${path}.tmp`)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await unlink(`${path}.tmp`);\n }\n }\n};\n\nexport default writeFile;\n","// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileContents = (contents: any): void => {\n if (typeof contents !== \"string\" && !(contents instanceof ArrayBuffer) && !ArrayBuffer.isView(contents)) {\n throw new TypeError(\"File contents must be a string, ArrayBuffer, or ArrayBuffer view.\");\n }\n};\n\nexport default assertValidFileContents;\n","const encoder = new TextEncoder();\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst toUint8Array = (contents: any) => {\n if (contents instanceof Uint8Array) {\n return contents;\n }\n\n if (typeof contents === \"string\") {\n return encoder.encode(contents);\n }\n\n if (contents instanceof ArrayBuffer) {\n return new Uint8Array(contents);\n }\n\n if (ArrayBuffer.isView(contents)) {\n const bytes = contents.buffer.slice(contents.byteOffset, contents.byteOffset + contents.byteLength);\n\n return new Uint8Array(bytes);\n }\n\n throw new TypeError(\"Invalid contents type. Expected string or ArrayBuffer.\");\n};\n\nexport default toUint8Array;\n","import type { Stats } from \"node:fs\";\nimport { chmodSync, chownSync, mkdirSync, renameSync, statSync, unlinkSync, writeFileSync as nodeWriteFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\n\nimport { F_OK } from \"./constants\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { WriteFileOptions } from \"./types\";\nimport assertValidFileContents from \"./utils/assert-valid-file-contents\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\nimport toUint8Array from \"./utils/to-uint-8-array\";\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeFileSync = (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions): void => {\n // eslint-disable-next-line no-param-reassign\n options = {\n encoding: \"utf8\",\n flag: \"w\",\n overwrite: true,\n recursive: true,\n ...options,\n };\n\n assertValidFileOrDirectoryPath(path);\n assertValidFileContents(content);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n const pathExists = isAccessibleSync(path, F_OK);\n\n if (!pathExists && options.recursive) {\n const directory = dirname(path);\n\n if (!isAccessibleSync(directory, F_OK)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(directory, { recursive: true });\n }\n }\n\n let stat: Stats | undefined;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n nodeWriteFileSync(`${path}.tmp`, toUint8Array(content), { encoding: options.encoding, flag: options.flag });\n\n if (pathExists && !options.overwrite) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n stat = statSync(path);\n\n if (options.chown === undefined) {\n // eslint-disable-next-line no-param-reassign\n options.chown = { gid: stat.gid, uid: stat.uid };\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n renameSync(path, `${path}.bak`);\n }\n\n const temporaryPath = `${path}.tmp`;\n\n if (options.chown) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n chownSync(temporaryPath, options.chown.uid, options.chown.gid);\n } catch {\n // On linux permissionless filesystems like exfat and fat32 the entire filesystem is normally owned by root,\n // and trying to chown it causes as permissions error.\n }\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n chmodSync(temporaryPath, stat && !options.mode ? stat.mode : options.mode ?? 0o666);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n renameSync(temporaryPath, path);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });\n } finally {\n if (isAccessibleSync(`${path}.tmp`)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n unlinkSync(`${path}.tmp`);\n }\n }\n};\n\nexport default writeFileSync;\n","import { readFile } from \"node:fs/promises\";\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport detectIndentFn from \"detect-indent\";\n\nimport { R_OK } from \"./constants\";\nimport isAccessible from \"./is-accessible\";\nimport type { WriteJsonOptions } from \"./types\";\nimport writeFile from \"./write-file\";\n\nconst writeJson = async (path: URL | string, data: unknown, options: WriteJsonOptions = {}): Promise<void> => {\n const { detectIndent, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: \"\\t\", ...options };\n\n let indent = indentOption;\n let trailingNewline = \"\\n\";\n\n if (await isAccessible(path, R_OK)) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const file = await readFile(path, \"utf8\");\n\n if (detectIndent) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const { indent: dIndent } = detectIndentFn(file);\n\n indent = dIndent as string;\n }\n\n trailingNewline = file.endsWith(\"\\n\") ? \"\\n\" : \"\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n }\n }\n\n // @ts-expect-error - `replacer` is a valid argument for `JSON.stringify`\n const json = stringify(data, replacer, indent);\n\n await writeFile(path, `${json}${trailingNewline}`, writeOptions);\n};\n\nexport default writeJson;\n","// Detect either spaces or tabs but not both to properly handle tabs for indentation and spaces for alignment\nconst INDENT_REGEX = /^(?:( )+|\\t+)/;\n\nconst INDENT_TYPE_SPACE = 'space';\nconst INDENT_TYPE_TAB = 'tab';\n\n/**\nMake a Map that counts how many indents/unindents have occurred for a given size and how many lines follow a given indentation.\n\nThe key is a concatenation of the indentation type (s = space and t = tab) and the size of the indents/unindents.\n\n```\nindents = {\n\tt3: [1, 0],\n\tt4: [1, 5],\n\ts5: [1, 0],\n\ts12: [1, 0],\n}\n```\n*/\nfunction makeIndentsMap(string, ignoreSingleSpaces) {\n\tconst indents = new Map();\n\n\t// Remember the size of previous line's indentation\n\tlet previousSize = 0;\n\tlet previousIndentType;\n\n\t// Indents key (ident type + size of the indents/unindents)\n\tlet key;\n\n\tfor (const line of string.split(/\\n/g)) {\n\t\tif (!line) {\n\t\t\t// Ignore empty lines\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet indent;\n\t\tlet indentType;\n\t\tlet use;\n\t\tlet weight;\n\t\tlet entry;\n\t\tconst matches = line.match(INDENT_REGEX);\n\n\t\tif (matches === null) {\n\t\t\tpreviousSize = 0;\n\t\t\tpreviousIndentType = '';\n\t\t} else {\n\t\t\tindent = matches[0].length;\n\t\t\tindentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;\n\n\t\t\t// Ignore single space unless it's the only indent detected to prevent common false positives\n\t\t\tif (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (indentType !== previousIndentType) {\n\t\t\t\tpreviousSize = 0;\n\t\t\t}\n\n\t\t\tpreviousIndentType = indentType;\n\n\t\t\tuse = 1;\n\t\t\tweight = 0;\n\n\t\t\tconst indentDifference = indent - previousSize;\n\t\t\tpreviousSize = indent;\n\n\t\t\t// Previous line have same indent?\n\t\t\tif (indentDifference === 0) {\n\t\t\t\t// Not a new \"use\" of the current indent:\n\t\t\t\tuse = 0;\n\t\t\t\t// But do add a bit to it for breaking ties:\n\t\t\t\tweight = 1;\n\t\t\t\t// We use the key from previous loop\n\t\t\t} else {\n\t\t\t\tconst absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;\n\t\t\t\tkey = encodeIndentsKey(indentType, absoluteIndentDifference);\n\t\t\t}\n\n\t\t\t// Update the stats\n\t\t\tentry = indents.get(key);\n\t\t\tentry = entry === undefined ? [1, 0] : [entry[0] + use, entry[1] + weight];\n\n\t\t\tindents.set(key, entry);\n\t\t}\n\t}\n\n\treturn indents;\n}\n\n// Encode the indent type and amount as a string (e.g. 's4') for use as a compound key in the indents Map.\nfunction encodeIndentsKey(indentType, indentAmount) {\n\tconst typeCharacter = indentType === INDENT_TYPE_SPACE ? 's' : 't';\n\treturn typeCharacter + String(indentAmount);\n}\n\n// Extract the indent type and amount from a key of the indents Map.\nfunction decodeIndentsKey(indentsKey) {\n\tconst keyHasTypeSpace = indentsKey[0] === 's';\n\tconst type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;\n\n\tconst amount = Number(indentsKey.slice(1));\n\n\treturn {type, amount};\n}\n\n// Return the key (e.g. 's4') from the indents Map that represents the most common indent,\n// or return undefined if there are no indents.\nfunction getMostUsedKey(indents) {\n\tlet result;\n\tlet maxUsed = 0;\n\tlet maxWeight = 0;\n\n\tfor (const [key, [usedCount, weight]] of indents) {\n\t\tif (usedCount > maxUsed || (usedCount === maxUsed && weight > maxWeight)) {\n\t\t\tmaxUsed = usedCount;\n\t\t\tmaxWeight = weight;\n\t\t\tresult = key;\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction makeIndentString(type, amount) {\n\tconst indentCharacter = type === INDENT_TYPE_SPACE ? ' ' : '\\t';\n\treturn indentCharacter.repeat(amount);\n}\n\nexport default function detectIndent(string) {\n\tif (typeof string !== 'string') {\n\t\tthrow new TypeError('Expected a string');\n\t}\n\n\t// Identify indents while skipping single space indents to avoid common edge cases (e.g. code comments)\n\t// If no indents are identified, run again and include all indents for comprehensive detection\n\tlet indents = makeIndentsMap(string, true);\n\tif (indents.size === 0) {\n\t\tindents = makeIndentsMap(string, false);\n\t}\n\n\tconst keyOfMostUsedIndent = getMostUsedKey(indents);\n\n\tlet type;\n\tlet amount = 0;\n\tlet indent = '';\n\n\tif (keyOfMostUsedIndent !== undefined) {\n\t\t({type, amount} = decodeIndentsKey(keyOfMostUsedIndent));\n\t\tindent = makeIndentString(type, amount);\n\t}\n\n\treturn {\n\t\tamount,\n\t\ttype,\n\t\tindent,\n\t};\n}\n","import { readFileSync } from \"node:fs\";\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport detectIndentFn from \"detect-indent\";\n\nimport { R_OK } from \"./constants\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { WriteJsonOptions } from \"./types\";\nimport writeFileSync from \"./write-file-sync\";\n\nconst writeJsonSync = (path: URL | string, data: unknown, options: WriteJsonOptions = {}): void => {\n const { detectIndent, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: \"\\t\", ...options };\n\n let indent = indentOption;\n let trailingNewline = \"\\n\";\n\n if (isAccessibleSync(path, R_OK)) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const file = readFileSync(path, \"utf8\");\n\n if (detectIndent) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const { indent: dIndent } = detectIndentFn(file);\n\n indent = dIndent as string;\n }\n\n trailingNewline = file.endsWith(\"\\n\") ? \"\\n\" : \"\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n }\n }\n\n // @ts-expect-error - `replacer` is a valid argument for `JSON.stringify`\n const json = stringify(data, replacer, indent);\n\n writeFileSync(path, `${json}${trailingNewline}`, writeOptions);\n};\n\nexport default writeJsonSync;\n","import type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToStringOptions } from \"yaml\";\nimport { stringify } from \"yaml\";\n\nimport type { YamlReplacer } from \"./types\";\nimport writeFile from \"./write-file\";\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype Options = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions;\n\nasync function writeYaml(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n options?: Options,\n): Promise<void>;\nasync function writeYaml(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n replacer?: YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: Options | number | string,\n): Promise<void>;\n// eslint-disable-next-line func-style\nasync function writeYaml(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types\n data: any,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n replacer?: Options | YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: Options | number | string,\n): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const content = typeof replacer === \"function\" || Array.isArray(replacer) ? stringify(data, replacer, options) : stringify(data, replacer as YamlReplacer);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n await writeFile(path, content);\n}\n\nexport default writeYaml;\n","import type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToStringOptions } from \"yaml\";\nimport { stringify } from \"yaml\";\n\nimport type { YamlReplacer } from \"./types\";\nimport writeFileSync from \"./write-file-sync\";\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype Options = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions;\n\nfunction writeYamlSync(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n options?: Options,\n): void;\nfunction writeYamlSync(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n replacer?: YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: Options | number | string,\n): void;\n// eslint-disable-next-line func-style\nfunction writeYamlSync(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types\n data: any,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n replacer?: Options | YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: number | string | (CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions),\n): void {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const content = typeof replacer === \"function\" || Array.isArray(replacer) ? stringify(data, replacer, options) : stringify(data, replacer as YamlReplacer);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n writeFileSync(path, content);\n}\n\nexport default writeYamlSync;\n"]}
1
+ {"version":3,"sources":["../src/walk.ts","../src/utils/assert-valid-file-or-directory-path.ts","../src/utils/glob-to-regex.ts","../src/utils/walk-include.ts","../src/collect.ts","../src/walk-sync.ts","../src/collect-sync.ts","../src/constants.ts","../src/empty-dir.ts","../src/empty-dir-sync.ts","../src/eol.ts","../src/find-up.ts","../src/find-up-sync.ts","../src/is-accessible.ts","../src/is-accessible-sync.ts","../src/read-file.ts","../src/read-file-sync.ts","../src/read-json.ts","../src/read-json-sync.ts","../src/read-yaml.ts","../src/read-yaml-sync.ts","../src/remove.ts","../src/remove-sync.ts","../src/write-file.ts","../src/utils/assert-valid-file-contents.ts","../src/utils/to-uint-8-array.ts","../src/write-file-sync.ts","../src/write-json.ts","../../../node_modules/.pnpm/detect-indent@7.0.1/node_modules/detect-indent/index.js","../src/write-json-sync.ts","../src/write-yaml.ts","../src/write-yaml-sync.ts"],"names":["readdir","realpath","stat","basename","join","normalize","resolve","assertValidFileOrDirectoryPath","fileOrDirectoryPath","assert_valid_file_or_directory_path_default","globToRegExp","glob","reString","glob_to_regex_default","walkInclude","path","extensions","match","skip","extension","pattern","walk_include_default","_createWalkEntry","normalizePath","name","info","walk","directory","followSymlinks","includeDirectories","includeFiles","includeSymlinks","maxDepth","mappedMatch","mappedSkip","to_path_default","entry","error","walk_error_default","collect","options","config","entries","collect_default","readdirSync","realpathSync","statSync","walkSync","collectSync","collect_sync_default","F_OK","R_OK","W_OK","X_OK","FIND_UP_STOP","existsSync","mkdir","rm","emptyDir","dir","item","empty_dir_default","mkdirSync","rmSync","empty_dir_sync_default","platform","regDetect","LF","CRLF","EOL","detect","content","d","crlf","newline","lf","format","eol","dirname","isAbsolute","parse","findUp","cwd","root","stopPath","stopAt","type","getMatchers","currentDirectory","fileName","filePath","stats","find_up_default","findUpSync","find_up_sync_default","access","isAccessible","mode","is_accessible_default","accessSync","isAccessibleSync","is_accessible_sync_default","nodeReadFile","brotliDecompress","unzip","decompressionMethods","buffer","callback","readFile","permission_error_default","compression","encoding","flag","reject","result","read_file_default","nodeReadFileSync","brotliDecompressSync","unzipSync","readFileSync","decompressed","read_file_sync_default","readJson","reviver","data","beforeParse","color","parse_json_default","read_json_default","readJsonSync","read_json_sync_default","readYaml","parseOptions","read_yaml_default","readYamlSync","read_yaml_sync_default","unlink","remove","remove_default","unlinkSync","removeSync","remove_sync_default","chmod","chown","rename","nodeStat","nodeWriteFile","assertValidFileContents","contents","assert_valid_file_contents_default","encoder","toUint8Array","bytes","to_uint_8_array_default","writeFile","pathExists","temporaryPath","write_file_default","chmodSync","chownSync","renameSync","nodeWriteFileSync","writeFileSync","write_file_sync_default","INDENT_REGEX","INDENT_TYPE_SPACE","INDENT_TYPE_TAB","makeIndentsMap","string","ignoreSingleSpaces","indents","previousSize","previousIndentType","key","line","indent","indentType","use","weight","matches","indentDifference","absoluteIndentDifference","encodeIndentsKey","indentAmount","decodeIndentsKey","indentsKey","amount","getMostUsedKey","maxUsed","maxWeight","usedCount","makeIndentString","detectIndent","keyOfMostUsedIndent","writeJson","indentOption","replacer","stringify","writeOptions","trailingNewline","file","dIndent","json","write_json_default","writeJsonSync","write_json_sync_default","writeYaml","write_yaml_default","writeYamlSync","write_yaml_sync_default"],"mappings":"0HAMA,OA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GAAGC,CAAa,EAAI,CAAE,OAAQ,IAAM,GAAG9J,CAAQ,EAE7HuI,EAASoB,EACTI,EAAkB;AAAA,EAEtB,GAAIlG,EAAiBtF,EAAM,CAAI,EAC3B,GAAI,CAEA,IAAMyL,EAAOjF,GAAaxG,EAAM,MAAM,EAEtC,GAAIiL,EAAc,CAEd,GAAM,CAAE,OAAQS,CAAQ,EAAIT,EAAeQ,CAAI,EAE/CzB,EAAS0B,CACb,CAEAF,EAAkBC,EAAK,SAAS;AAAA,CAAI,EAAI;AAAA,EAAO,EAEnD,OAASnK,EAAY,CAEjB,GAAIA,EAAM,OAAS,SACf,MAAMA,CAEd,CAIJ,IAAMqK,EAAOL,EAAUzE,EAAMwE,EAAUrB,CAAM,EAE7CZ,EAAcpJ,EAAM,GAAG2L,CAAI,GAAGH,CAAe,GAAID,CAAY,CACjE,EAEOO,GAAQD,GC3Cf,OAAS,aAAAP,MAAiB,OAuB1B,eAAeS,GACX/L,EAEA6G,EAEAwE,EAEA5J,EACa,CAEb,IAAM+B,EAAU,OAAO6H,GAAa,YAAc,MAAM,QAAQA,CAAQ,EAAIC,EAAUzE,EAAMwE,EAAU5J,CAAO,EAAI6J,EAAUzE,EAAMwE,CAAwB,EAGzJ,MAAMvC,EAAU9I,EAAMwD,CAAO,CACjC,CAEA,IAAOwI,GAAQD,GCvCf,OAAS,aAAAT,MAAiB,OAuB1B,SAASW,GACLjM,EAEA6G,EAEAwE,EAEA5J,EACI,CAEJ,IAAM+B,EAAU,OAAO6H,GAAa,YAAc,MAAM,QAAQA,CAAQ,EAAIC,EAAUzE,EAAMwE,EAAU5J,CAAO,EAAI6J,EAAUzE,EAAMwE,CAAwB,EAGzJjC,EAAcpJ,EAAMwD,CAAO,CAC/B,CAEA,IAAO0I,GAAQD","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdir, realpath, stat } from \"node:fs/promises\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = async (path: string): Promise<WalkEntry> => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = await stat(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/**\n * Walks the file tree rooted at root, yielding each file or directory in the\n * tree filtered according to the given options.\n * Options:\n * - maxDepth?: number = Infinity;\n * - includeFiles?: boolean = true;\n * - includeDirs?: boolean = true;\n * - includeSymlinks?: boolean = true;\n * - followSymlinks?: boolean = false;\n * - extensions?: string[];\n * - match?: string | ReadonlyArray<string>;\n * - skip?: string | ReadonlyArray<string>;\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default async function* walk(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): AsyncIterableIterator<WalkEntry> {\n assertValidFileOrDirectoryPath(directory);\n\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield await _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,security/detect-non-literal-fs-filename,no-loops/no-loops\n for await (const entry of await readdir(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = await realpath(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walk(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileOrDirectoryPath = (fileOrDirectoryPath: any): void => {\n if (!fileOrDirectoryPath || (!(fileOrDirectoryPath instanceof URL) && typeof fileOrDirectoryPath !== \"string\")) {\n throw new TypeError(\"Path must be a non-empty string or URL.\");\n }\n};\n\nexport default assertValidFileOrDirectoryPath;\n","const globToRegExp = (glob: string): RegExp => {\n const reString = glob\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.\\*/g, \".([^/]*)\") // Replace .* with .([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\*\\*/g, \"(.*)\") // Replace ** with (.*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/(?<!\\.)\\*(?!\\*)/g, \"([^/]*)\") // Replace * (not preceded by . or followed by *) with ([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\?/g, \"[^/]\") // Replace ? with [^/]\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.(?!\\*)/g, \"\\\\.\") // Escape . that is not preceded by *\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\{/g, \"(\") // Replace { with (\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\}/g, \")\") // Replace } with )\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/,/g, \"|\") // Replace , with |\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\[!(.*?)\\]/g, \"[^$1]\"); // Replace [!number-number] with [^number-number]\n\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp,security/detect-non-literal-regexp\n return new RegExp(`^${reString}$`);\n};\n\nexport default globToRegExp;\n","const walkInclude = (path: string, extensions?: string[], match?: RegExp[], skip?: RegExp[]): boolean => {\n if (extensions && !extensions.some((extension): boolean => path.endsWith(extension))) {\n return false;\n }\n\n if (match && !match.some((pattern): boolean => pattern.test(path))) {\n return false;\n }\n\n return !(skip && skip.some((pattern): boolean => pattern.test(path)));\n};\n\nexport default walkInclude;\n","import type { WalkOptions } from \"./types\";\nimport walk from \"./walk\";\n\nconst collect = async (directory: string, options: WalkOptions = {}): Promise<string[]> => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for await (const entry of walk(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collect;\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n/** Create {@linkcode WalkEntry} for the `path` synchronously. */\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = (path: string): WalkEntry => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = statSync(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/** Same as {@linkcode walk} but uses synchronous ops */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default function* walkSync(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): IterableIterator<WalkEntry> {\n assertValidFileOrDirectoryPath(directory);\n\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops,security/detect-non-literal-fs-filename\n for (const entry of readdirSync(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = realpathSync(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walkSync(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","import type { WalkOptions } from \"./types\";\nimport walkSync from \"./walk-sync\";\n\nconst collectSync = (directory: string, options: WalkOptions = {}): string[] => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const entry of walkSync(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collectSync;\n","/** Is the path visible to the calling process? */\nexport const F_OK = 0; // constants?.F_OK\n\n/** Is the path readable to the calling process? */\nexport const R_OK = 4; // constants?.R_OK\n\n/** Is the path writable to the calling process? */\nexport const W_OK = 2; // constants?.W_OK\n\n/** Is the path executable to the calling process? */\nexport const X_OK = 1; // constants?.X_OK\n\nexport const FIND_UP_STOP = Symbol(\"findUpStop\");\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport { existsSync } from \"node:fs\";\nimport { mkdir, readdir, rm } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nimport type { EmptyDirOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/**\n * Ensures that a directory is empty.\n * Deletes directory contents if the directory is not empty.\n * If the directory does not exist, it is created.\n * The directory itself is not deleted.\n */\n// eslint-disable-next-line unicorn/prevent-abbreviations\nconst emptyDir = async (dir: URL | string, options?: EmptyDirOptions): Promise<void> => {\n assertValidFileOrDirectoryPath(dir);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(dir)) {\n // if not exist. then create it\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await mkdir(dir, { recursive: true });\n\n return;\n }\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax,security/detect-non-literal-fs-filename\n for await (const item of await readdir(dir)) {\n await rm(join(toPath(dir), item), { ...options, force: true, recursive: true });\n }\n}\n\nexport default emptyDir;\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport { existsSync, mkdirSync, readdirSync, rmSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nimport type { EmptyDirOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/**\n * Ensures that a directory is empty.\n * Deletes directory contents if the directory is not empty.\n * If the directory does not exist, it is created.\n * The directory itself is not deleted.\n */\n// eslint-disable-next-line unicorn/prevent-abbreviations\nconst emptyDir = (dir: URL | string, options?: EmptyDirOptions): void => {\n assertValidFileOrDirectoryPath(dir);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(dir)) {\n // if not exist. then create it\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(dir, { recursive: true });\n\n return;\n }\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax,security/detect-non-literal-fs-filename\n for (const item of readdirSync(dir)) {\n rmSync(join(toPath(dir), item), { ...options, force: true, recursive: true });\n }\n}\n\nexport default emptyDir;\n","import { platform } from \"node:process\";\n\nconst regDetect = /\\r?\\n/g;\n\n/** End-of-line character for POSIX platforms such as macOS and Linux. */\nexport const LF = \"\\n\" as const;\n\n/** End-of-line character for Windows platforms. */\nexport const CRLF = \"\\r\\n\" as const;\n\n/**\n * End-of-line character evaluated for the current platform.\n */\nexport const EOL: \"\\n\" | \"\\r\\n\" = platform === \"win32\" ? CRLF : LF;\n\n/**\n * Detect the EOL character for string input.\n * Returns null if no newline.\n */\nexport const detect = (content: string): typeof EOL | null => {\n const d = content.match(regDetect);\n\n if (!d || d.length === 0) {\n return null;\n }\n\n const crlf = d.filter((newline) => newline === CRLF).length;\n const lf = d.length - crlf;\n\n return crlf > lf ? CRLF : LF;\n};\n\n/**\n * Format the file to the targeted EOL.\n */\nexport const format = (content: string, eol: typeof EOL): string => content.replaceAll(regDetect, eol);\n","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, parse, resolve } from \"node:path\";\n\nimport { FIND_UP_STOP } from \"./constants\";\nimport type { FindUpOptions, Match } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: ReadonlyArray<string> | string[] | string | ((directory: string) => Match | Promise<Match>),\n options: FindUpOptions = {},\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): Promise<string | undefined> => {\n if (typeof name !== \"string\" && !Array.isArray(name) && typeof name !== \"function\") {\n throw new TypeError(\"The `name` argument must be of type `string` or `string[]`\");\n }\n\n const cwd = options.cwd ? toPath(options.cwd) : process.cwd();\n\n assertValidFileOrDirectoryPath(cwd);\n\n let directory = resolve(cwd);\n\n const { root } = parse(directory);\n const stopPath = toPath(options.stopAt ?? root);\n\n assertValidFileOrDirectoryPath(stopPath);\n\n const stopAt = resolve(directory, stopPath);\n const type = options.type ?? \"file\";\n\n const getMatchers = async function (currentDirectory: string): Promise<(string | typeof FIND_UP_STOP | undefined)[]> {\n if (typeof name === \"function\") {\n const match = await name(currentDirectory);\n\n return [match];\n }\n\n if (typeof name === \"string\") {\n return [name];\n }\n\n if (Array.isArray(name)) {\n return name as string[];\n }\n\n return [name];\n };\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n // eslint-disable-next-line no-await-in-loop,no-loops/no-loops,no-restricted-syntax\n for await (const fileName of await getMatchers(directory)) {\n if (fileName === FIND_UP_STOP) {\n return undefined;\n }\n\n if (fileName === undefined) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = await stat(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUp;\n","import { statSync } from \"node:fs\";\nimport { dirname, isAbsolute, parse, resolve } from \"node:path\";\n\nimport { FIND_UP_STOP } from \"./constants\";\nimport type { FindUpOptions, Match } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: ReadonlyArray<string> | string[] | string | ((directory: string) => Match),\n options: FindUpOptions = {},\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): string | undefined => {\n if (typeof name !== \"string\" && !Array.isArray(name) && typeof name !== \"function\") {\n throw new TypeError(\"The `name` argument must be of type `string` or `string[]`\");\n }\n\n const cwd = options.cwd ? toPath(options.cwd) : process.cwd();\n\n assertValidFileOrDirectoryPath(cwd);\n\n let directory = resolve(cwd);\n\n const { root } = parse(directory);\n const stopPath = toPath(options.stopAt ?? root);\n\n assertValidFileOrDirectoryPath(stopPath);\n\n const stopAt = resolve(directory, stopPath);\n const type = options.type ?? \"file\";\n\n const getMatchers = function (currentDirectory: string): (string | typeof FIND_UP_STOP | undefined)[] {\n if (typeof name === \"function\") {\n const match = name(currentDirectory);\n\n return [match];\n }\n\n if (typeof name === \"string\") {\n return [name];\n }\n\n if (Array.isArray(name)) {\n return name as string[];\n }\n\n return [name];\n };\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const fileName of getMatchers(directory)) {\n if (fileName === FIND_UP_STOP) {\n return undefined;\n }\n\n if (fileName === undefined) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = statSync(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUpSync;\n","import { access } from \"node:fs/promises\";\n\nimport { F_OK } from \"./constants\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/** Returns a Promise that resolves to a boolean indicating if the path is accessible or not. */\nasync function isAccessible(path: URL | string, mode?: number): Promise<boolean>;\n// eslint-disable-next-line func-style\nasync function isAccessible(path: URL | string, mode: number = F_OK): Promise<boolean> {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n await access(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessible;\n","import { accessSync } from \"node:fs\";\n\nimport { F_OK } from \"./constants\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/** Returns a boolean indicating if the path is accessible or not. */\nfunction isAccessibleSync(path: URL | string, mode?: number): boolean;\n// eslint-disable-next-line func-style\nfunction isAccessibleSync(path: URL | string, mode: number = F_OK): boolean {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n accessSync(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessibleSync;\n","import { readFile as nodeReadFile } from \"node:fs/promises\";\nimport { brotliDecompress, unzip } from \"node:zlib\";\n\nimport { R_OK } from \"./constants\";\nimport PermissionError from \"./error/permission-error\";\nimport isAccessible from \"./is-accessible\";\nimport type { ContentType, ReadFileOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst decompressionMethods = {\n brotli: brotliDecompress,\n gzip: unzip,\n none: (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => {\n callback(null, buffer);\n },\n} as const;\n\nconst readFile = async <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: URL | string,\n options?: O,\n): Promise<ContentType<O>> => {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n if (!(await isAccessible(path))) {\n throw new PermissionError(`unable to read the non-accessible file: ${path}`);\n }\n\n if (!(await isAccessible(path, R_OK))) {\n throw new Error(`Unable to read the non-readable file: ${path}`);\n }\n\n const { buffer, compression, encoding, flag } = options ?? {};\n\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n return await nodeReadFile(path, flag ? { encoding, flag } : { encoding })\n .then(\n async (content) =>\n // eslint-disable-next-line compat/compat\n await new Promise<ContentType<O> | undefined>((resolve, reject) => {\n decompressionMethods[compression ?? \"none\"](content, (error, result) => {\n if (error) {\n reject(error);\n } else {\n resolve((buffer ? result : result.toString()) as ContentType<O>);\n }\n });\n }),\n )\n .catch((error: unknown) => {\n throw error;\n });\n};\n\nexport default readFile;\n","import { readFileSync as nodeReadFileSync } from \"node:fs\";\nimport { brotliDecompressSync, unzipSync } from \"node:zlib\";\n\nimport { R_OK } from \"./constants\";\nimport PermissionError from \"./error/permission-error\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { ContentType, ReadFileOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst decompressionMethods = {\n brotli: brotliDecompressSync,\n gzip: unzipSync,\n none: (buffer: Buffer) => buffer,\n} as const;\n\nconst readFileSync = <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: URL | string,\n options?: O,\n): ContentType<O> => {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n if (!isAccessibleSync(path)) {\n throw new PermissionError(`unable to read the non-accessible file: ${path}`);\n }\n\n if (!isAccessibleSync(path, R_OK)) {\n throw new PermissionError(`invalid access to read file at: ${path}`);\n }\n\n const { buffer, compression, encoding, flag } = options ?? {};\n\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const content = nodeReadFileSync(path, flag ? { encoding, flag } : { encoding });\n\n const decompressed = decompressionMethods[compression ?? \"none\"](content);\n\n return (buffer ? decompressed : decompressed.toString()) as ContentType<O>;\n};\n\nexport default readFileSync;\n","import type { JsonValue } from \"type-fest\";\n\nimport readFile from \"./read-file\";\nimport type { JsonReviver, ReadJsonOptions } from \"./types\";\nimport parseJson from \"./utils/parse-json\";\nimport toPath from \"./utils/to-path\";\n\nasync function readJson<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): Promise<T>;\n\nasync function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): Promise<T>;\n// eslint-disable-next-line func-style\nasync function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver | ReadJsonOptions, options?: ReadJsonOptions): Promise<T> {\n if (typeof reviver === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n const content = await readFile(path, {\n buffer: true,\n encoding: undefined,\n });\n\n // Unlike `buffer.toString()` and `fs.readFile(path, 'utf8')`, `TextDecoder` will remove BOM.\n let data = new TextDecoder().decode(content);\n\n const { beforeParse, color } = options ?? {};\n\n if (typeof beforeParse === \"function\") {\n data = beforeParse(data);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parseJson<T>(data, reviver, toPath(path), { color });\n}\n\nexport default readJson;\n","import type { JsonValue } from \"type-fest\";\n\nimport readFileSync from \"./read-file-sync\";\nimport type { JsonReviver, ReadJsonOptions } from \"./types\";\nimport parseJson from \"./utils/parse-json\";\nimport toPath from \"./utils/to-path\";\n\nfunction readJsonSync<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): T;\n\nfunction readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): T;\n// eslint-disable-next-line func-style\nfunction readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver | ReadJsonOptions, options?: ReadJsonOptions): T {\n if (typeof reviver === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n const content = readFileSync(path, {\n buffer: true,\n encoding: undefined,\n });\n\n // Unlike `buffer.toString()` and `fs.readFile(path, 'utf8')`, `TextDecoder` will remove BOM.\n let data = new TextDecoder().decode(content);\n\n const { beforeParse, color } = options ?? {};\n\n if (typeof beforeParse === \"function\") {\n data = beforeParse(data);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parseJson<T>(data, reviver, toPath(path), { color });\n}\n\nexport default readJsonSync;\n","import { parse } from \"yaml\";\n\nimport readFile from \"./read-file\";\nimport type { ReadYamlOptions, YamlReviver } from \"./types\";\n\nasync function readYaml<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">): Promise<R>;\nasync function readYaml<R = Record<string, unknown>>(\n path: URL | string,\n reviver?: YamlReviver,\n options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">,\n): Promise<R>;\n\n// eslint-disable-next-line func-style\nasync function readYaml<R = Record<string, unknown>>(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n reviver?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\"> | YamlReviver,\n options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">,\n): Promise<R> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const {\n buffer,\n compression,\n encoding = \"utf8\",\n flag,\n ...parseOptions\n } = options ?? {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const content = await readFile(path, { buffer, compression, encoding, flag });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n return (typeof reviver === \"function\" ? parse(content, reviver, parseOptions) : parse(content, parseOptions)) as R;\n}\n\nexport default readYaml;\n","import { parse } from \"yaml\";\n\nimport readFileSync from \"./read-file-sync\";\nimport type { ReadYamlOptions, YamlReviver } from \"./types\";\n\nfunction readYamlSync<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">): R;\nfunction readYamlSync<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">): R;\n// eslint-disable-next-line func-style\nfunction readYamlSync<R = Record<string, unknown>>(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n reviver?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\"> | YamlReviver,\n options?: ReadYamlOptions<\"brotli\" | \"gzip\" | \"none\">,\n): R {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const {\n buffer,\n compression,\n encoding = \"utf8\",\n flag,\n ...parseOptions\n } = options ?? {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const content = readFileSync(path, { buffer, compression, encoding, flag });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n return (typeof reviver === \"function\" ? parse(content, reviver, parseOptions) : parse(content, parseOptions)) as R;\n}\n\nexport default readYamlSync;\n","import { rm, unlink } from \"node:fs/promises\";\n\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\n\nconst remove = async (\n path: URL | string,\n options: {\n /**\n * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or\n * `EPERM` error is encountered, Node.js will retry the operation with a linear\n * backoff wait of `retryDelay` ms longer on each try. This option represents the\n * number of retries. This option is ignored if the `recursive` option is not\n * `true`.\n * @default 0\n */\n maxRetries?: number | undefined;\n /**\n * The amount of time in milliseconds to wait between retries.\n * This option is ignored if the `recursive` option is not `true`.\n * @default 100\n */\n retryDelay?: number | undefined;\n } = {},\n): Promise<void> => {\n assertValidFileOrDirectoryPath(path);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await unlink(path);\n } catch {\n /* empty */\n }\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n await rm(path, { force: true, maxRetries: options?.maxRetries, recursive: true, retryDelay: options?.retryDelay });\n } catch {\n /* empty */\n }\n};\n\nexport default remove;\n","import { rmSync, unlinkSync } from \"node:fs\";\n\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\n\nconst removeSync = (\n path: URL | string,\n options: {\n /**\n * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or\n * `EPERM` error is encountered, Node.js will retry the operation with a linear\n * backoff wait of `retryDelay` ms longer on each try. This option represents the\n * number of retries. This option is ignored if the `recursive` option is not\n * `true`.\n * @default 0\n */\n maxRetries?: number | undefined;\n /**\n * The amount of time in milliseconds to wait between retries.\n * This option is ignored if the `recursive` option is not `true`.\n * @default 100\n */\n retryDelay?: number | undefined;\n } = {},\n): void => {\n assertValidFileOrDirectoryPath(path);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n unlinkSync(path);\n } catch {\n /* empty */\n }\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n rmSync(path, { force: true, maxRetries: options?.maxRetries, recursive: true, retryDelay: options?.retryDelay });\n } catch {\n /* empty */\n }\n};\n\nexport default removeSync;\n","import type { Stats } from \"node:fs\";\nimport { chmod, chown, mkdir, rename, stat as nodeStat, unlink, writeFile as nodeWriteFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nimport { F_OK } from \"./constants\";\nimport isAccessible from \"./is-accessible\";\nimport type { WriteFileOptions } from \"./types\";\nimport assertValidFileContents from \"./utils/assert-valid-file-contents\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\nimport toUint8Array from \"./utils/to-uint-8-array\";\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeFile = async (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions): Promise<void> => {\n // eslint-disable-next-line no-param-reassign\n options = {\n encoding: \"utf8\",\n flag: \"w\",\n overwrite: true,\n recursive: true,\n ...options,\n };\n\n assertValidFileOrDirectoryPath(path);\n assertValidFileContents(content);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n const pathExists = await isAccessible(path, F_OK);\n\n if (!pathExists && options.recursive) {\n const directory = dirname(path);\n\n if (!(await isAccessible(directory, F_OK))) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await mkdir(directory, { recursive: true });\n }\n }\n\n let stat: Stats | undefined;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await nodeWriteFile(`${path}.tmp`, toUint8Array(content), { encoding: options.encoding, flag: options.flag });\n\n if (pathExists && !options.overwrite) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n stat = await nodeStat(path);\n\n if (options.chown === undefined) {\n // eslint-disable-next-line no-param-reassign\n options.chown = { gid: stat.gid, uid: stat.uid };\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await rename(path, `${path}.bak`);\n }\n\n const temporaryPath = `${path}.tmp`;\n\n if (options.chown) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await chown(temporaryPath, options.chown.uid, options.chown.gid);\n } catch {\n // On linux permissionless filesystems like exfat and fat32 the entire filesystem is normally owned by root,\n // and trying to chown it causes as permissions error.\n }\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await chmod(temporaryPath, stat && !options.mode ? stat.mode : options.mode ?? 0o666);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await rename(temporaryPath, path);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });\n } finally {\n if (await isAccessible(`${path}.tmp`)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await unlink(`${path}.tmp`);\n }\n }\n};\n\nexport default writeFile;\n","// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileContents = (contents: any): void => {\n if (typeof contents !== \"string\" && !(contents instanceof ArrayBuffer) && !ArrayBuffer.isView(contents)) {\n throw new TypeError(\"File contents must be a string, ArrayBuffer, or ArrayBuffer view.\");\n }\n};\n\nexport default assertValidFileContents;\n","const encoder = new TextEncoder();\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst toUint8Array = (contents: any) => {\n if (contents instanceof Uint8Array) {\n return contents;\n }\n\n if (typeof contents === \"string\") {\n return encoder.encode(contents);\n }\n\n if (contents instanceof ArrayBuffer) {\n return new Uint8Array(contents);\n }\n\n if (ArrayBuffer.isView(contents)) {\n const bytes = contents.buffer.slice(contents.byteOffset, contents.byteOffset + contents.byteLength);\n\n return new Uint8Array(bytes);\n }\n\n throw new TypeError(\"Invalid contents type. Expected string or ArrayBuffer.\");\n};\n\nexport default toUint8Array;\n","import type { Stats } from \"node:fs\";\nimport { chmodSync, chownSync, mkdirSync, renameSync, statSync, unlinkSync, writeFileSync as nodeWriteFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\n\nimport { F_OK } from \"./constants\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { WriteFileOptions } from \"./types\";\nimport assertValidFileContents from \"./utils/assert-valid-file-contents\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\nimport toUint8Array from \"./utils/to-uint-8-array\";\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeFileSync = (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions): void => {\n // eslint-disable-next-line no-param-reassign\n options = {\n encoding: \"utf8\",\n flag: \"w\",\n overwrite: true,\n recursive: true,\n ...options,\n };\n\n assertValidFileOrDirectoryPath(path);\n assertValidFileContents(content);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n const pathExists = isAccessibleSync(path, F_OK);\n\n if (!pathExists && options.recursive) {\n const directory = dirname(path);\n\n if (!isAccessibleSync(directory, F_OK)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(directory, { recursive: true });\n }\n }\n\n let stat: Stats | undefined;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n nodeWriteFileSync(`${path}.tmp`, toUint8Array(content), { encoding: options.encoding, flag: options.flag });\n\n if (pathExists && !options.overwrite) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n stat = statSync(path);\n\n if (options.chown === undefined) {\n // eslint-disable-next-line no-param-reassign\n options.chown = { gid: stat.gid, uid: stat.uid };\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n renameSync(path, `${path}.bak`);\n }\n\n const temporaryPath = `${path}.tmp`;\n\n if (options.chown) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n chownSync(temporaryPath, options.chown.uid, options.chown.gid);\n } catch {\n // On linux permissionless filesystems like exfat and fat32 the entire filesystem is normally owned by root,\n // and trying to chown it causes as permissions error.\n }\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n chmodSync(temporaryPath, stat && !options.mode ? stat.mode : options.mode ?? 0o666);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n renameSync(temporaryPath, path);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });\n } finally {\n if (isAccessibleSync(`${path}.tmp`)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n unlinkSync(`${path}.tmp`);\n }\n }\n};\n\nexport default writeFileSync;\n","import { readFile } from \"node:fs/promises\";\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport detectIndentFn from \"detect-indent\";\n\nimport { R_OK } from \"./constants\";\nimport isAccessible from \"./is-accessible\";\nimport type { WriteJsonOptions } from \"./types\";\nimport writeFile from \"./write-file\";\n\nconst writeJson = async (path: URL | string, data: unknown, options: WriteJsonOptions = {}): Promise<void> => {\n const { detectIndent, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: \"\\t\", ...options };\n\n let indent = indentOption;\n let trailingNewline = \"\\n\";\n\n if (await isAccessible(path, R_OK)) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const file = await readFile(path, \"utf8\");\n\n if (detectIndent) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const { indent: dIndent } = detectIndentFn(file);\n\n indent = dIndent as string;\n }\n\n trailingNewline = file.endsWith(\"\\n\") ? \"\\n\" : \"\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n }\n }\n\n // @ts-expect-error - `replacer` is a valid argument for `JSON.stringify`\n const json = stringify(data, replacer, indent);\n\n await writeFile(path, `${json}${trailingNewline}`, writeOptions);\n};\n\nexport default writeJson;\n","// Detect either spaces or tabs but not both to properly handle tabs for indentation and spaces for alignment\nconst INDENT_REGEX = /^(?:( )+|\\t+)/;\n\nconst INDENT_TYPE_SPACE = 'space';\nconst INDENT_TYPE_TAB = 'tab';\n\n/**\nMake a Map that counts how many indents/unindents have occurred for a given size and how many lines follow a given indentation.\n\nThe key is a concatenation of the indentation type (s = space and t = tab) and the size of the indents/unindents.\n\n```\nindents = {\n\tt3: [1, 0],\n\tt4: [1, 5],\n\ts5: [1, 0],\n\ts12: [1, 0],\n}\n```\n*/\nfunction makeIndentsMap(string, ignoreSingleSpaces) {\n\tconst indents = new Map();\n\n\t// Remember the size of previous line's indentation\n\tlet previousSize = 0;\n\tlet previousIndentType;\n\n\t// Indents key (ident type + size of the indents/unindents)\n\tlet key;\n\n\tfor (const line of string.split(/\\n/g)) {\n\t\tif (!line) {\n\t\t\t// Ignore empty lines\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet indent;\n\t\tlet indentType;\n\t\tlet use;\n\t\tlet weight;\n\t\tlet entry;\n\t\tconst matches = line.match(INDENT_REGEX);\n\n\t\tif (matches === null) {\n\t\t\tpreviousSize = 0;\n\t\t\tpreviousIndentType = '';\n\t\t} else {\n\t\t\tindent = matches[0].length;\n\t\t\tindentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;\n\n\t\t\t// Ignore single space unless it's the only indent detected to prevent common false positives\n\t\t\tif (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (indentType !== previousIndentType) {\n\t\t\t\tpreviousSize = 0;\n\t\t\t}\n\n\t\t\tpreviousIndentType = indentType;\n\n\t\t\tuse = 1;\n\t\t\tweight = 0;\n\n\t\t\tconst indentDifference = indent - previousSize;\n\t\t\tpreviousSize = indent;\n\n\t\t\t// Previous line have same indent?\n\t\t\tif (indentDifference === 0) {\n\t\t\t\t// Not a new \"use\" of the current indent:\n\t\t\t\tuse = 0;\n\t\t\t\t// But do add a bit to it for breaking ties:\n\t\t\t\tweight = 1;\n\t\t\t\t// We use the key from previous loop\n\t\t\t} else {\n\t\t\t\tconst absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;\n\t\t\t\tkey = encodeIndentsKey(indentType, absoluteIndentDifference);\n\t\t\t}\n\n\t\t\t// Update the stats\n\t\t\tentry = indents.get(key);\n\t\t\tentry = entry === undefined ? [1, 0] : [entry[0] + use, entry[1] + weight];\n\n\t\t\tindents.set(key, entry);\n\t\t}\n\t}\n\n\treturn indents;\n}\n\n// Encode the indent type and amount as a string (e.g. 's4') for use as a compound key in the indents Map.\nfunction encodeIndentsKey(indentType, indentAmount) {\n\tconst typeCharacter = indentType === INDENT_TYPE_SPACE ? 's' : 't';\n\treturn typeCharacter + String(indentAmount);\n}\n\n// Extract the indent type and amount from a key of the indents Map.\nfunction decodeIndentsKey(indentsKey) {\n\tconst keyHasTypeSpace = indentsKey[0] === 's';\n\tconst type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;\n\n\tconst amount = Number(indentsKey.slice(1));\n\n\treturn {type, amount};\n}\n\n// Return the key (e.g. 's4') from the indents Map that represents the most common indent,\n// or return undefined if there are no indents.\nfunction getMostUsedKey(indents) {\n\tlet result;\n\tlet maxUsed = 0;\n\tlet maxWeight = 0;\n\n\tfor (const [key, [usedCount, weight]] of indents) {\n\t\tif (usedCount > maxUsed || (usedCount === maxUsed && weight > maxWeight)) {\n\t\t\tmaxUsed = usedCount;\n\t\t\tmaxWeight = weight;\n\t\t\tresult = key;\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction makeIndentString(type, amount) {\n\tconst indentCharacter = type === INDENT_TYPE_SPACE ? ' ' : '\\t';\n\treturn indentCharacter.repeat(amount);\n}\n\nexport default function detectIndent(string) {\n\tif (typeof string !== 'string') {\n\t\tthrow new TypeError('Expected a string');\n\t}\n\n\t// Identify indents while skipping single space indents to avoid common edge cases (e.g. code comments)\n\t// If no indents are identified, run again and include all indents for comprehensive detection\n\tlet indents = makeIndentsMap(string, true);\n\tif (indents.size === 0) {\n\t\tindents = makeIndentsMap(string, false);\n\t}\n\n\tconst keyOfMostUsedIndent = getMostUsedKey(indents);\n\n\tlet type;\n\tlet amount = 0;\n\tlet indent = '';\n\n\tif (keyOfMostUsedIndent !== undefined) {\n\t\t({type, amount} = decodeIndentsKey(keyOfMostUsedIndent));\n\t\tindent = makeIndentString(type, amount);\n\t}\n\n\treturn {\n\t\tamount,\n\t\ttype,\n\t\tindent,\n\t};\n}\n","import { readFileSync } from \"node:fs\";\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport detectIndentFn from \"detect-indent\";\n\nimport { R_OK } from \"./constants\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { WriteJsonOptions } from \"./types\";\nimport writeFileSync from \"./write-file-sync\";\n\nconst writeJsonSync = (path: URL | string, data: unknown, options: WriteJsonOptions = {}): void => {\n const { detectIndent, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: \"\\t\", ...options };\n\n let indent = indentOption;\n let trailingNewline = \"\\n\";\n\n if (isAccessibleSync(path, R_OK)) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const file = readFileSync(path, \"utf8\");\n\n if (detectIndent) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const { indent: dIndent } = detectIndentFn(file);\n\n indent = dIndent as string;\n }\n\n trailingNewline = file.endsWith(\"\\n\") ? \"\\n\" : \"\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n }\n }\n\n // @ts-expect-error - `replacer` is a valid argument for `JSON.stringify`\n const json = stringify(data, replacer, indent);\n\n writeFileSync(path, `${json}${trailingNewline}`, writeOptions);\n};\n\nexport default writeJsonSync;\n","import type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToStringOptions } from \"yaml\";\nimport { stringify } from \"yaml\";\n\nimport type { YamlReplacer } from \"./types\";\nimport writeFile from \"./write-file\";\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype Options = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions;\n\nasync function writeYaml(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n options?: Options,\n): Promise<void>;\nasync function writeYaml(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n replacer?: YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: Options | number | string,\n): Promise<void>;\n// eslint-disable-next-line func-style\nasync function writeYaml(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types\n data: any,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n replacer?: Options | YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: Options | number | string,\n): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const content = typeof replacer === \"function\" || Array.isArray(replacer) ? stringify(data, replacer, options) : stringify(data, replacer as YamlReplacer);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n await writeFile(path, content);\n}\n\nexport default writeYaml;\n","import type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToStringOptions } from \"yaml\";\nimport { stringify } from \"yaml\";\n\nimport type { YamlReplacer } from \"./types\";\nimport writeFileSync from \"./write-file-sync\";\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype Options = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions;\n\nfunction writeYamlSync(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n options?: Options,\n): void;\nfunction writeYamlSync(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n replacer?: YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: Options | number | string,\n): void;\n// eslint-disable-next-line func-style\nfunction writeYamlSync(\n path: URL | string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types\n data: any,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n replacer?: Options | YamlReplacer,\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n options?: number | string | (CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions),\n): void {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const content = typeof replacer === \"function\" || Array.isArray(replacer) ? stringify(data, replacer, options) : stringify(data, replacer as YamlReplacer);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n writeFileSync(path, content);\n}\n\nexport default writeYamlSync;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/fs",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Human friendly file system utilities for Node.js",
5
5
  "keywords": [
6
6
  "anolilab",