@visulima/fs 1.5.0 → 1.7.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,22 @@
1
+ ## @visulima/fs [1.7.0](https://github.com/visulima/visulima/compare/@visulima/fs@1.6.0...@visulima/fs@1.7.0) (2024-03-16)
2
+
3
+
4
+ ### Features
5
+
6
+ * **package:** added cjs and esm export ([#335](https://github.com/visulima/visulima/issues/335)) ([62b873a](https://github.com/visulima/visulima/commit/62b873a76d2a5356e7596d3a7e299d8e51eb2fcd))
7
+
8
+ ## @visulima/fs [1.6.0](https://github.com/visulima/visulima/compare/@visulima/fs@1.5.0...@visulima/fs@1.6.0) (2024-03-14)
9
+
10
+
11
+ ### Features
12
+
13
+ * **fs:** added matcher and FIND_UP_STOP to findup ([#344](https://github.com/visulima/visulima/issues/344)) ([34a5844](https://github.com/visulima/visulima/commit/34a584450416b8e99b70b920357cbde57e2c6b5b))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * **fs:** added missing constants exports ([51915b2](https://github.com/visulima/visulima/commit/51915b257fa416c7fbcca24f16eb98132273cf4c))
19
+
1
20
  ## @visulima/fs [1.5.0](https://github.com/visulima/visulima/compare/@visulima/fs@1.4.0...@visulima/fs@1.5.0) (2024-03-14)
2
21
 
3
22
 
package/README.md CHANGED
@@ -191,11 +191,15 @@ console.log(file);
191
191
 
192
192
  #### name
193
193
 
194
- Type: `string | string[]`
194
+ Type: `string | string[] | (dir: string) => string | symbole | undefined`
195
195
 
196
196
  The name of the file or directory to find.
197
197
  > If an array is specified, the first item that exists will be returned.
198
198
 
199
+ > A function that will be called with each directory until it returns a string with the path, which stops the search, or the root directory has been reached and nothing was found. Useful if you want to match files with certain patterns, set of permissions, or other advanced use-cases.
200
+ >
201
+ > When using async mode, the matcher may optionally be an async or promise-returning function that returns the path.
202
+
199
203
  #### options
200
204
 
201
205
  Type: `object`
package/dist/index.cjs CHANGED
@@ -8,29 +8,34 @@ var path = require('path');
8
8
  var fs = require('fs');
9
9
  var zlib = require('zlib');
10
10
 
11
- var j=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},u=j;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}$`)},F=z;var K=(e,t,r,i)=>t&&!t.some(n=>e.endsWith(n))||r&&!r.some(n=>n.test(e))?!1:!(i&&i.some(n=>n.test(e))),g=K;var Z=async e=>{let t=path.normalize(e),r=path.basename(t),i=await promises.stat(t);return {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:r,path:t}};async function*h(e,{extensions:t,followSymlinks:r=!1,includeDirs:i=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a,maxDepth:l=Number.POSITIVE_INFINITY,skip:d}={}){if(u(e),l<0)return;let f=a?a.map(o=>typeof o=="string"?F(o):o):void 0,c=d?d.map(o=>typeof o=="string"?F(o):o):void 0;if(e=path.resolve(chunkQHWRBSYR_cjs.a(e)),i&&g(e,t,f,c)&&(yield await Z(e)),!(l<1||!g(e,void 0,void 0,c)))try{for await(let o of await promises.readdir(e,{withFileTypes:!0})){let p=path.join(e,o.name);if(o.isSymbolicLink())if(r)p=await promises.realpath(p);else if(s&&g(p,t,f,c))yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:p};else continue;o.isSymbolicLink()||o.isDirectory()?yield*h(p,{extensions:t,followSymlinks:r,includeDirs:i,includeFiles:n,includeSymlinks:s,match:f,maxDepth:l-1,skip:c}):o.isFile()&&n&&g(p,t,f,c)&&(yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:p});}}catch(o){throw o instanceof chunkKXYI7M76_cjs.a?o:new chunkKXYI7M76_cjs.a(o,e)}}var ee=async(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},i=[];for await(let n of h(e,r))i.push(n.path);return i},te=ee;var ce=e=>{let t=path.normalize(e),r=path.basename(t),i=fs.statSync(t);return {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:r,path:t}};function*k(e,{extensions:t,followSymlinks:r=!1,includeDirs:i=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a,maxDepth:l=Number.POSITIVE_INFINITY,skip:d}={}){if(u(e),l<0)return;let f=a?a.map(o=>typeof o=="string"?F(o):o):void 0,c=d?d.map(o=>typeof o=="string"?F(o):o):void 0;if(e=path.resolve(chunkQHWRBSYR_cjs.a(e)),i&&g(e,t,f,c)&&(yield ce(e)),!(l<1||!g(e,void 0,void 0,c)))try{for(let o of fs.readdirSync(e,{withFileTypes:!0})){let p=path.join(e,o.name);if(o.isSymbolicLink())if(r)p=fs.realpathSync(p);else if(s&&g(p,t,f,c))yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:p};else continue;o.isSymbolicLink()||o.isDirectory()?yield*k(p,{extensions:t,followSymlinks:r,includeDirs:i,includeFiles:n,includeSymlinks:s,match:f,maxDepth:l-1,skip:c}):o.isFile()&&n&&g(p,t,f,c)&&(yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:p});}}catch(o){throw o instanceof chunkKXYI7M76_cjs.a?o:new chunkKXYI7M76_cjs.a(o,e)}}var le=(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},i=[];for(let n of k(e,r))i.push(n.path);return i},me=le;var ge=async(e,t={})=>{if(typeof e!="string"&&!Array.isArray(e))throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=t.cwd?chunkQHWRBSYR_cjs.a(t.cwd):process.cwd();u(r);let i=path.resolve(r),{root:n}=path.parse(i),s=chunkQHWRBSYR_cjs.a(t.stopAt??n);u(s);let a=path.resolve(i,s),l=t.type??"file",d=typeof e=="string"?[e]:e;for(;i&&i!==a&&i!==n;){for await(let f of d){let c=path.isAbsolute(f)?f:path.resolve(i,f);try{let o=await promises.stat(c);if(l==="file"&&o.isFile()||l==="directory"&&o.isDirectory())return c}catch{}}i=path.dirname(i);}},we=ge;var he=(e,t={})=>{if(typeof e!="string"&&!Array.isArray(e))throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=t.cwd?chunkQHWRBSYR_cjs.a(t.cwd):process.cwd();u(r);let i=path.resolve(r),{root:n}=path.parse(i),s=chunkQHWRBSYR_cjs.a(t.stopAt??n);u(s);let a=path.resolve(i,s),l=t.type??"file",d=typeof e=="string"?[e]:e;for(;i&&i!==a&&i!==n;){for(let f of d){let c=path.isAbsolute(f)?f:path.resolve(i,f);try{let o=fs.statSync(c);if(l==="file"&&o.isFile()||l==="directory"&&o.isDirectory())return c}catch{}}i=path.dirname(i);}},ke=he;async function xe(e,t=0){u(e),e=chunkQHWRBSYR_cjs.a(e);try{return await promises.access(e,t),!0}catch{return !1}}var w=xe;function Te(e,t=0){u(e),e=chunkQHWRBSYR_cjs.a(e);try{return fs.accessSync(e,t),!0}catch{return !1}}var b=Te;var We={brotli:zlib.brotliDecompress,gzip:zlib.unzip,none:(e,t)=>{t(null,e);}},Le=async(e,t)=>{if(u(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:i,encoding:n,flag:s}=t??{};return await promises.readFile(e,s?{encoding:n,flag:s}:{encoding:n}).then(async a=>await new Promise((l,d)=>{We[i??"none"](a,(f,c)=>{f?d(f):l(r?c:c.toString());});})).catch(a=>{throw a})},I=Le;var ve={brotli:zlib.brotliDecompressSync,gzip:zlib.unzipSync,none:e=>e},Ve=(e,t)=>{if(u(e),e=chunkQHWRBSYR_cjs.a(e),!b(e))throw new chunkKXYI7M76_cjs.b(`unable to read the non-accessible file: ${e}`);if(!b(e,4))throw new chunkKXYI7M76_cjs.b(`invalid access to read file at: ${e}`);let{buffer:r,compression:i,encoding:n,flag:s}=t??{},a=fs.readFileSync(e,s?{encoding:n,flag:s}:{encoding:n}),l=ve[i??"none"](a);return r?l:l.toString()},D=Ve;async function $e(e,t,r){typeof t=="object"&&(r=t,t=void 0);let i=await I(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(i),{beforeParse:s,color:a}=r??{};return typeof s=="function"&&(n=s(n)),chunkQHWRBSYR_cjs.b(n,t,chunkQHWRBSYR_cjs.a(e),{color:a})}var Ne=$e;function Ce(e,t,r){typeof t=="object"&&(r=t,t=void 0);let i=D(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(i),{beforeParse:s,color:a}=r??{};return typeof s=="function"&&(n=s(n)),chunkQHWRBSYR_cjs.b(n,t,chunkQHWRBSYR_cjs.a(e),{color:a})}var _e=Ce;var Be=e=>{if(typeof e!="string"&&!(e instanceof ArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},J=Be;var je=new TextEncoder,ze=e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return je.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.")},A=ze;var Qe=async(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},u(e),J(t),e=chunkQHWRBSYR_cjs.a(e);try{let i=await w(e,0);if(!i&&r.recursive){let a=path.dirname(e);await w(a,0)||await promises.mkdir(a,{recursive:!0});}let n;await promises.writeFile(`${e}.tmp`,A(t),{encoding:r.encoding,flag:r.flag}),i&&!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(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{await w(`${e}.tmp`)&&await promises.unlink(`${e}.tmp`);}},v=Qe;var st=(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},u(e),J(t),e=chunkQHWRBSYR_cjs.a(e);try{let i=b(e,0);if(!i&&r.recursive){let a=path.dirname(e);b(a,0)||fs.mkdirSync(a,{recursive:!0});}let n;fs.writeFileSync(`${e}.tmp`,A(t),{encoding:r.encoding,flag:r.flag}),i&&!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(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{b(`${e}.tmp`)&&fs.unlinkSync(`${e}.tmp`);}},V=st;var at=/^(?:( )+|\t+)/,x="space",_="tab";function C(e,t){let r=new Map,i=0,n,s;for(let a of e.split(/\n/g)){if(!a)continue;let l,d,f,c,o,p=a.match(at);if(p===null)i=0,n="";else {if(l=p[0].length,d=p[1]?x:_,t&&d===x&&l===1)continue;d!==n&&(i=0),n=d,f=1,c=0;let T=l-i;if(i=l,T===0)f=0,c=1;else {let B=T>0?T:-T;s=ft(d,B);}o=r.get(s),o=o===void 0?[1,0]:[o[0]+f,o[1]+c],r.set(s,o);}}return r}function ft(e,t){return (e===x?"s":"t")+String(t)}function ct(e){let r=e[0]==="s"?x:_,i=Number(e.slice(1));return {type:r,amount:i}}function lt(e){let t,r=0,i=0;for(let[n,[s,a]]of e)(s>r||s===r&&a>i)&&(r=s,i=a,t=n);return t}function mt(e,t){return (e===x?" ":" ").repeat(t)}function E(e){if(typeof e!="string")throw new TypeError("Expected a string");let t=C(e,!0);t.size===0&&(t=C(e,!1));let r=lt(t),i,n=0,s="";return r!==void 0&&({type:i,amount:n}=ct(r),s=mt(i,n)),{amount:n,type:i,indent:s}}var pt=async(e,t,r={})=>{let{detectIndent:i,indent:n,replacer:s,stringify:a=JSON.stringify,...l}={indent:" ",...r},d=n,f=`
12
- `;if(await w(e,4))try{let o=await promises.readFile(e,"utf8");if(i){let{indent:p}=E(o);d=p;}f=o.endsWith(`
11
+ var B=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},u=B;var j=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=j;var z=(e,t,i,r)=>t&&!t.some(o=>e.endsWith(o))||i&&!i.some(o=>o.test(e))?!1:!(r&&r.some(o=>o.test(e))),g=z;var ee=async e=>{let t=path.normalize(e),i=path.basename(t),r=await promises.stat(t);return {isDirectory:r.isDirectory,isFile:r.isFile,isSymbolicLink:r.isSymbolicLink,name:i,path:t}};async function*R(e,{extensions:t,followSymlinks:i=!1,includeDirs:r=!0,includeFiles:o=!0,includeSymlinks:s=!0,match:f,maxDepth:l=Number.POSITIVE_INFINITY,skip:m}={}){if(u(e),l<0)return;let a=f?f.map(n=>typeof n=="string"?b(n):n):void 0,c=m?m.map(n=>typeof n=="string"?b(n):n):void 0;if(e=path.resolve(chunkQHWRBSYR_cjs.a(e)),r&&g(e,t,a,c)&&(yield await ee(e)),!(l<1||!g(e,void 0,void 0,c)))try{for await(let n of await promises.readdir(e,{withFileTypes:!0})){let p=path.join(e,n.name);if(n.isSymbolicLink())if(i)p=await promises.realpath(p);else if(s&&g(p,t,a,c))yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:p};else continue;n.isSymbolicLink()||n.isDirectory()?yield*R(p,{extensions:t,followSymlinks:i,includeDirs:r,includeFiles:o,includeSymlinks:s,match:a,maxDepth:l-1,skip:c}):n.isFile()&&o&&g(p,t,a,c)&&(yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:p});}}catch(n){throw n instanceof chunkKXYI7M76_cjs.a?n:new chunkKXYI7M76_cjs.a(n,e)}}var te=async(e,t={})=>{let i={extensions:["js","mjs","cjs","ts"],...t},r=[];for await(let o of R(e,i))r.push(o.path);return r},re=te;var le=e=>{let t=path.normalize(e),i=path.basename(t),r=fs.statSync(t);return {isDirectory:r.isDirectory,isFile:r.isFile,isSymbolicLink:r.isSymbolicLink,name:i,path:t}};function*x(e,{extensions:t,followSymlinks:i=!1,includeDirs:r=!0,includeFiles:o=!0,includeSymlinks:s=!0,match:f,maxDepth:l=Number.POSITIVE_INFINITY,skip:m}={}){if(u(e),l<0)return;let a=f?f.map(n=>typeof n=="string"?b(n):n):void 0,c=m?m.map(n=>typeof n=="string"?b(n):n):void 0;if(e=path.resolve(chunkQHWRBSYR_cjs.a(e)),r&&g(e,t,a,c)&&(yield le(e)),!(l<1||!g(e,void 0,void 0,c)))try{for(let n of fs.readdirSync(e,{withFileTypes:!0})){let p=path.join(e,n.name);if(n.isSymbolicLink())if(i)p=fs.realpathSync(p);else if(s&&g(p,t,a,c))yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:p};else continue;n.isSymbolicLink()||n.isDirectory()?yield*x(p,{extensions:t,followSymlinks:i,includeDirs:r,includeFiles:o,includeSymlinks:s,match:a,maxDepth:l-1,skip:c}):n.isFile()&&o&&g(p,t,a,c)&&(yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:p});}}catch(n){throw n instanceof chunkKXYI7M76_cjs.a?n:new chunkKXYI7M76_cjs.a(n,e)}}var de=(e,t={})=>{let i={extensions:["js","mjs","cjs","ts"],...t},r=[];for(let o of x(e,i))r.push(o.path);return r},me=de;var F=0,P=4,pe=2,ye=1,k=Symbol("findUpStop");var Fe=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 i=t.cwd?chunkQHWRBSYR_cjs.a(t.cwd):process.cwd();u(i);let r=path.resolve(i),{root:o}=path.parse(r),s=chunkQHWRBSYR_cjs.a(t.stopAt??o);u(s);let f=path.resolve(r,s),l=t.type??"file",m=async function(a){return typeof e=="function"?[await e(a)]:typeof e=="string"?[e]:Array.isArray(e)?e:[e]};for(;r&&r!==f&&r!==o;){for await(let a of await m(r)){if(a===k)return;if(a===void 0)continue;let c=path.isAbsolute(a)?a:path.resolve(r,a);try{let n=await promises.stat(c);if(l==="file"&&n.isFile()||l==="directory"&&n.isDirectory())return c}catch{}}r=path.dirname(r);}},Se=Fe;var Pe=(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 i=t.cwd?chunkQHWRBSYR_cjs.a(t.cwd):process.cwd();u(i);let r=path.resolve(i),{root:o}=path.parse(r),s=chunkQHWRBSYR_cjs.a(t.stopAt??o);u(s);let f=path.resolve(r,s),l=t.type??"file",m=function(a){return typeof e=="function"?[e(a)]:typeof e=="string"?[e]:Array.isArray(e)?e:[e]};for(;r&&r!==f&&r!==o;){for(let a of m(r)){if(a===k)return;if(a===void 0)continue;let c=path.isAbsolute(a)?a:path.resolve(r,a);try{let n=fs.statSync(c);if(l==="file"&&n.isFile()||l==="directory"&&n.isDirectory())return c}catch{}}r=path.dirname(r);}},ke=Pe;async function Ee(e,t=0){u(e),e=chunkQHWRBSYR_cjs.a(e);try{return await promises.access(e,t),!0}catch{return !1}}var w=Ee;function Je(e,t=0){u(e),e=chunkQHWRBSYR_cjs.a(e);try{return fs.accessSync(e,t),!0}catch{return !1}}var O=Je;var De={brotli:zlib.brotliDecompress,gzip:zlib.unzip,none:(e,t)=>{t(null,e);}},Le=async(e,t)=>{if(u(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:i,compression:r,encoding:o,flag:s}=t??{};return await promises.readFile(e,s?{encoding:o,flag:s}:{encoding:o}).then(async f=>await new Promise((l,m)=>{De[r??"none"](f,(a,c)=>{a?m(a):l(i?c:c.toString());});})).catch(f=>{throw f})},L=Le;var Ve={brotli:zlib.brotliDecompressSync,gzip:zlib.unzipSync,none:e=>e},$e=(e,t)=>{if(u(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:i,compression:r,encoding:o,flag:s}=t??{},f=fs.readFileSync(e,s?{encoding:o,flag:s}:{encoding:o}),l=Ve[r??"none"](f);return i?l:l.toString()},_=$e;async function Ke(e,t,i){typeof t=="object"&&(i=t,t=void 0);let r=await L(e,{buffer:!0,encoding:void 0}),o=new TextDecoder().decode(r),{beforeParse:s,color:f}=i??{};return typeof s=="function"&&(o=s(o)),chunkQHWRBSYR_cjs.b(o,t,chunkQHWRBSYR_cjs.a(e),{color:f})}var Ce=Ke;function Me(e,t,i){typeof t=="object"&&(i=t,t=void 0);let r=_(e,{buffer:!0,encoding:void 0}),o=new TextDecoder().decode(r),{beforeParse:s,color:f}=i??{};return typeof s=="function"&&(o=s(o)),chunkQHWRBSYR_cjs.b(o,t,chunkQHWRBSYR_cjs.a(e),{color:f})}var Be=Me;var je=e=>{if(typeof e!="string"&&!(e instanceof ArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},U=je;var ze=new TextEncoder,Ye=e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return ze.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.")},W=Ye;var tt=async(e,t,i)=>{i={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...i},u(e),U(t),e=chunkQHWRBSYR_cjs.a(e);try{let r=await w(e,0);if(!r&&i.recursive){let f=path.dirname(e);await w(f,0)||await promises.mkdir(f,{recursive:!0});}let o;await promises.writeFile(`${e}.tmp`,W(t),{encoding:i.encoding,flag:i.flag}),r&&!i.overwrite&&(o=await promises.stat(e),i.chown===void 0&&(i.chown={gid:o.gid,uid:o.uid}),await promises.rename(e,`${e}.bak`));let s=`${e}.tmp`;if(i.chown)try{await promises.chown(s,i.chown.uid,i.chown.gid);}catch{}await promises.chmod(s,o&&!i.mode?o.mode:i.mode??438),await promises.rename(s,e);}catch(r){throw new Error(`Failed to write file at: ${e} - ${r.message}`,{cause:r})}finally{await w(`${e}.tmp`)&&await promises.unlink(`${e}.tmp`);}},v=tt;var ct=(e,t,i)=>{i={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...i},u(e),U(t),e=chunkQHWRBSYR_cjs.a(e);try{let r=O(e,0);if(!r&&i.recursive){let f=path.dirname(e);O(f,0)||fs.mkdirSync(f,{recursive:!0});}let o;fs.writeFileSync(`${e}.tmp`,W(t),{encoding:i.encoding,flag:i.flag}),r&&!i.overwrite&&(o=fs.statSync(e),i.chown===void 0&&(i.chown={gid:o.gid,uid:o.uid}),fs.renameSync(e,`${e}.bak`));let s=`${e}.tmp`;if(i.chown)try{fs.chownSync(s,i.chown.uid,i.chown.gid);}catch{}fs.chmodSync(s,o&&!i.mode?o.mode:i.mode??438),fs.renameSync(s,e);}catch(r){throw new Error(`Failed to write file at: ${e} - ${r.message}`,{cause:r})}finally{O(`${e}.tmp`)&&fs.unlinkSync(`${e}.tmp`);}},N=ct;var lt=/^(?:( )+|\t+)/,T="space",C="tab";function K(e,t){let i=new Map,r=0,o,s;for(let f of e.split(/\n/g)){if(!f)continue;let l,m,a,c,n,p=f.match(lt);if(p===null)r=0,o="";else {if(l=p[0].length,m=p[1]?T:C,t&&m===T&&l===1)continue;m!==o&&(r=0),o=m,a=1,c=0;let A=l-r;if(r=l,A===0)a=0,c=1;else {let M=A>0?A:-A;s=dt(m,M);}n=i.get(s),n=n===void 0?[1,0]:[n[0]+a,n[1]+c],i.set(s,n);}}return i}function dt(e,t){return (e===T?"s":"t")+String(t)}function mt(e){let i=e[0]==="s"?T:C,r=Number(e.slice(1));return {type:i,amount:r}}function pt(e){let t,i=0,r=0;for(let[o,[s,f]]of e)(s>i||s===i&&f>r)&&(i=s,r=f,t=o);return t}function yt(e,t){return (e===T?" ":" ").repeat(t)}function E(e){if(typeof e!="string")throw new TypeError("Expected a string");let t=K(e,!0);t.size===0&&(t=K(e,!1));let i=pt(t),r,o=0,s="";return i!==void 0&&({type:r,amount:o}=mt(i),s=yt(r,o)),{amount:o,type:r,indent:s}}var gt=async(e,t,i={})=>{let{detectIndent:r,indent:o,replacer:s,stringify:f=JSON.stringify,...l}={indent:" ",...i},m=o,a=`
12
+ `;if(await w(e,4))try{let n=await promises.readFile(e,"utf8");if(r){let{indent:p}=E(n);m=p;}a=n.endsWith(`
13
13
  `)?`
14
- `:"";}catch(o){if(o.code!=="ENOENT")throw o}let c=a(t,s,d);await v(e,`${c}${f}`,l);},yt=pt;var gt=(e,t,r={})=>{let{detectIndent:i,indent:n,replacer:s,stringify:a=JSON.stringify,...l}={indent:" ",...r},d=n,f=`
15
- `;if(b(e,4))try{let o=fs.readFileSync(e,"utf8");if(i){let{indent:p}=E(o);d=p;}f=o.endsWith(`
14
+ `:"";}catch(n){if(n.code!=="ENOENT")throw n}let c=f(t,s,m);await v(e,`${c}${a}`,l);},wt=gt;var Ft=(e,t,i={})=>{let{detectIndent:r,indent:o,replacer:s,stringify:f=JSON.stringify,...l}={indent:" ",...i},m=o,a=`
15
+ `;if(O(e,4))try{let n=fs.readFileSync(e,"utf8");if(r){let{indent:p}=E(n);m=p;}a=n.endsWith(`
16
16
  `)?`
17
- `:"";}catch(o){if(o.code!=="ENOENT")throw o}let c=a(t,s,d);V(e,`${c}${f}`,l);},wt=gt;
17
+ `:"";}catch(n){if(n.code!=="ENOENT")throw n}let c=f(t,s,m);N(e,`${c}${a}`,l);},St=Ft;
18
18
 
19
- exports.collect = te;
19
+ exports.FIND_UP_STOP = k;
20
+ exports.F_OK = F;
21
+ exports.R_OK = P;
22
+ exports.W_OK = pe;
23
+ exports.X_OK = ye;
24
+ exports.collect = re;
20
25
  exports.collectSync = me;
21
- exports.findUp = we;
26
+ exports.findUp = Se;
22
27
  exports.findUpSync = ke;
23
28
  exports.isAccessible = w;
24
- exports.isAccessibleSync = b;
25
- exports.readFile = I;
26
- exports.readFileSync = D;
27
- exports.readJson = Ne;
28
- exports.readJsonSync = _e;
29
- exports.walk = h;
30
- exports.walkSync = k;
29
+ exports.isAccessibleSync = O;
30
+ exports.readFile = L;
31
+ exports.readFileSync = _;
32
+ exports.readJson = Ce;
33
+ exports.readJsonSync = Be;
34
+ exports.walk = R;
35
+ exports.walkSync = x;
31
36
  exports.writeFile = v;
32
- exports.writeFileSync = V;
33
- exports.writeJson = yt;
34
- exports.writeJsonSync = wt;
37
+ exports.writeFileSync = N;
38
+ exports.writeJson = wt;
39
+ exports.writeJsonSync = St;
35
40
  //# sourceMappingURL=out.js.map
36
41
  //# 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/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/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"],"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","dirname","isAbsolute","parse","findUp","cwd","root","stopPath","stopAt","type","search","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","content","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","chmod","chown","mkdir","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","mkdirSync","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"],"mappings":"6HAMA,OAAS,WAAAA,EAAS,YAAAC,EAAU,QAAAC,MAAY,cACxC,OAAS,YAAAC,EAAU,QAAAC,EAAM,aAAAC,EAAW,WAAAC,MAAe,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,E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O,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","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, parse, resolve } from \"node:path\";\n\nimport type { FindUpOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: string[] | string,\n options: FindUpOptions = {},\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): Promise<string | undefined> => {\n if (typeof name !== \"string\" && !Array.isArray(name)) {\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\n assertValidFileOrDirectoryPath(stopPath);\n\n const stopAt = resolve(directory, stopPath);\n const type = options.type ?? \"file\";\n\n const search = typeof name === \"string\" ? [name] : name;\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 search) {\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 type { FindUpOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: string[] | string,\n options: FindUpOptions = {},\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): string | undefined => {\n if (typeof name !== \"string\" && !Array.isArray(name)) {\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 search = typeof name === \"string\" ? [name] : name;\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 search) {\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> | undefined> => {\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> | undefined => {\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 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"]}
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/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/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"],"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","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","content","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","chmod","chown","mkdir","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","mkdirSync","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"],"mappings":"6HAMA,OAAS,WAAAA,EAAS,YAAAC,EAAU,QAAAC,MAAY,cACxC,OAAS,YAAAC,EAAU,QAAAC,EAAM,aAAAC,EAAW,WAAAC,MAAe,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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E,EAAM,MAAM,EAExC,GAAIoJ,EAAc,CAEd,GAAM,CAAE,OAAQS,CAAQ,EAAIT,EAAeQ,CAAI,EAE/CzB,EAAS0B,CACb,CAEAF,EAAkBC,EAAK,SAAS;AAAA,CAAI,EAAI;AAAA,EAAO,EAEnD,OAAStI,EAAY,CAEjB,GAAIA,EAAM,OAAS,SACf,MAAMA,CAEd,CAIJ,IAAMwI,EAAOL,EAAUlE,EAAMiE,EAAUrB,CAAM,EAE7C,MAAMpB,EAAU/G,EAAM,GAAG8J,CAAI,GAAGH,CAAe,GAAID,CAAY,CACnE,EAEOK,GAAQT,GE5Cf,OAAS,gBAAApE,OAAoB,KAU7B,IAAM8E,GAAgB,CAAChK,EAAoBuF,EAAe9D,EAA4B,CAAC,IAAY,CAC/F,GAAM,CAAE,aAAA2H,EAAc,OAAQG,EAAc,SAAAC,EAAU,UAAAC,EAAY,KAAK,UAAW,GAAGC,CAAa,EAAI,CAAE,OAAQ,IAAM,GAAGjI,CAAQ,EAE7H0G,EAASoB,EACTI,EAAkB;AAAA,EAEtB,GAAI5F,EAAiB/D,EAAM,CAAI,EAC3B,GAAI,CAEA,IAAM4J,EAAO1E,GAAalF,EAAM,MAAM,EAEtC,GAAIoJ,EAAc,CAEd,GAAM,CAAE,OAAQS,CAAQ,EAAIT,EAAeQ,CAAI,EAE/CzB,EAAS0B,CACb,CAEAF,EAAkBC,EAAK,SAAS;AAAA,CAAI,EAAI;AAAA,EAAO,EAEnD,OAAStI,EAAY,CAEjB,GAAIA,EAAM,OAAS,SACf,MAAMA,CAEd,CAIJ,IAAMwI,EAAOL,EAAUlE,EAAMiE,EAAUrB,CAAM,EAE7CZ,EAAcvH,EAAM,GAAG8J,CAAI,GAAGH,CAAe,GAAID,CAAY,CACjE,EAEOO,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","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> | undefined> => {\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> | undefined => {\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 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"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { W as WalkOptions, F as FindUpOptions, R as ReadFileOptions, C as ContentType, a as ReadJsonOptions, J as JsonReviver, b as WalkEntry, c as WriteFileOptions, d as WriteJsonOptions } from './types-9INKTu78.cjs';
2
- export { e as CodeFrameLocation, f as JsonReplacer, g as ReadFileEncoding } from './types-9INKTu78.cjs';
1
+ import { W as WalkOptions, M as Match, F as FindUpOptions, R as ReadFileOptions, C as ContentType, a as ReadJsonOptions, J as JsonReviver, b as WalkEntry, c as WriteFileOptions, d as WriteJsonOptions } from './types-npDka8vJ.cjs';
2
+ export { i as CodeFrameLocation, f as FIND_UP_STOP, e as F_OK, j as JsonReplacer, g as R_OK, k as ReadFileEncoding, h as W_OK, X as X_OK } from './types-npDka8vJ.cjs';
3
3
  import { JsonValue } from 'type-fest';
4
4
  import 'node:fs';
5
5
 
@@ -7,9 +7,9 @@ declare const collect: (directory: string, options?: WalkOptions) => Promise<str
7
7
 
8
8
  declare const collectSync: (directory: string, options?: WalkOptions) => string[];
9
9
 
10
- declare const findUp: (name: string[] | string, options?: FindUpOptions) => Promise<string | undefined>;
10
+ declare const findUp: (name: string | string[] | readonly string[] | ((directory: string) => Match | Promise<Match>), options?: FindUpOptions) => Promise<string | undefined>;
11
11
 
12
- declare const findUpSync: (name: string[] | string, options?: FindUpOptions) => string | undefined;
12
+ declare const findUpSync: (name: string | string[] | readonly string[] | ((directory: string) => Match), options?: FindUpOptions) => string | undefined;
13
13
 
14
14
  declare function isAccessible(path: URL | string, mode?: number): Promise<boolean>;
15
15
 
@@ -37,4 +37,4 @@ declare const writeJson: (path: URL | string, data: unknown, options?: WriteJson
37
37
 
38
38
  declare const writeJsonSync: (path: URL | string, data: unknown, options?: WriteJsonOptions) => void;
39
39
 
40
- export { JsonReviver, ReadFileOptions, ReadJsonOptions, WalkEntry, WalkOptions, WriteFileOptions, WriteJsonOptions, collect, collectSync, findUp, findUpSync, isAccessible, isAccessibleSync, readFile, readFileSync, readJson, readJsonSync, walk, walkSync, writeFile, writeFileSync, writeJson, writeJsonSync };
40
+ export { FindUpOptions, JsonReviver, ReadFileOptions, ReadJsonOptions, WalkEntry, WalkOptions, WriteFileOptions, WriteJsonOptions, collect, collectSync, findUp, findUpSync, isAccessible, isAccessibleSync, readFile, readFileSync, readJson, readJsonSync, walk, walkSync, writeFile, writeFileSync, writeJson, writeJsonSync };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { W as WalkOptions, F as FindUpOptions, R as ReadFileOptions, C as ContentType, a as ReadJsonOptions, J as JsonReviver, b as WalkEntry, c as WriteFileOptions, d as WriteJsonOptions } from './types-9INKTu78.js';
2
- export { e as CodeFrameLocation, f as JsonReplacer, g as ReadFileEncoding } from './types-9INKTu78.js';
1
+ import { W as WalkOptions, M as Match, F as FindUpOptions, R as ReadFileOptions, C as ContentType, a as ReadJsonOptions, J as JsonReviver, b as WalkEntry, c as WriteFileOptions, d as WriteJsonOptions } from './types-npDka8vJ.js';
2
+ export { i as CodeFrameLocation, f as FIND_UP_STOP, e as F_OK, j as JsonReplacer, g as R_OK, k as ReadFileEncoding, h as W_OK, X as X_OK } from './types-npDka8vJ.js';
3
3
  import { JsonValue } from 'type-fest';
4
4
  import 'node:fs';
5
5
 
@@ -7,9 +7,9 @@ declare const collect: (directory: string, options?: WalkOptions) => Promise<str
7
7
 
8
8
  declare const collectSync: (directory: string, options?: WalkOptions) => string[];
9
9
 
10
- declare const findUp: (name: string[] | string, options?: FindUpOptions) => Promise<string | undefined>;
10
+ declare const findUp: (name: string | string[] | readonly string[] | ((directory: string) => Match | Promise<Match>), options?: FindUpOptions) => Promise<string | undefined>;
11
11
 
12
- declare const findUpSync: (name: string[] | string, options?: FindUpOptions) => string | undefined;
12
+ declare const findUpSync: (name: string | string[] | readonly string[] | ((directory: string) => Match), options?: FindUpOptions) => string | undefined;
13
13
 
14
14
  declare function isAccessible(path: URL | string, mode?: number): Promise<boolean>;
15
15
 
@@ -37,4 +37,4 @@ declare const writeJson: (path: URL | string, data: unknown, options?: WriteJson
37
37
 
38
38
  declare const writeJsonSync: (path: URL | string, data: unknown, options?: WriteJsonOptions) => void;
39
39
 
40
- export { JsonReviver, ReadFileOptions, ReadJsonOptions, WalkEntry, WalkOptions, WriteFileOptions, WriteJsonOptions, collect, collectSync, findUp, findUpSync, isAccessible, isAccessibleSync, readFile, readFileSync, readJson, readJsonSync, walk, walkSync, writeFile, writeFileSync, writeJson, writeJsonSync };
40
+ export { FindUpOptions, JsonReviver, ReadFileOptions, ReadJsonOptions, WalkEntry, WalkOptions, WriteFileOptions, WriteJsonOptions, collect, collectSync, findUp, findUpSync, isAccessible, isAccessibleSync, readFile, readFileSync, readJson, readJsonSync, walk, walkSync, writeFile, writeFileSync, writeJson, writeJsonSync };
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
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
4
  import { readdir, realpath, stat, access, readFile, mkdir, writeFile, rename, chown, chmod, unlink } from 'node:fs/promises';
5
5
  import { resolve, join, normalize, basename, parse, isAbsolute, dirname } from 'node:path';
6
6
  import { readdirSync, realpathSync, statSync, accessSync, readFileSync, mkdirSync, writeFileSync, renameSync, chownSync, chmodSync, unlinkSync } from 'node:fs';
7
7
  import { brotliDecompress, unzip, brotliDecompressSync, unzipSync } from 'node:zlib';
8
8
 
9
- var z=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},g=z;var K=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}$`)},S=K;var M=(e,t,r,i)=>t&&!t.some(n=>e.endsWith(n))||r&&!r.some(n=>n.test(e))?!1:!(i&&i.some(n=>n.test(e))),w=M;var ee=async e=>{let t=normalize(e),r=basename(t),i=await stat(t);return {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:r,path:t}};async function*k(e,{extensions:t,followSymlinks:r=!1,includeDirs:i=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a$2,maxDepth:l=Number.POSITIVE_INFINITY,skip:d}={}){if(g(e),l<0)return;let f=a$2?a$2.map(o=>typeof o=="string"?S(o):o):void 0,c=d?d.map(o=>typeof o=="string"?S(o):o):void 0;if(e=resolve(a(e)),i&&w(e,t,f,c)&&(yield await ee(e)),!(l<1||!w(e,void 0,void 0,c)))try{for await(let o of await readdir(e,{withFileTypes:!0})){let p=join(e,o.name);if(o.isSymbolicLink())if(r)p=await realpath(p);else if(s&&w(p,t,f,c))yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:p};else continue;o.isSymbolicLink()||o.isDirectory()?yield*k(p,{extensions:t,followSymlinks:r,includeDirs:i,includeFiles:n,includeSymlinks:s,match:f,maxDepth:l-1,skip:c}):o.isFile()&&n&&w(p,t,f,c)&&(yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:p});}}catch(o){throw o instanceof a$1?o:new a$1(o,e)}}var te=async(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},i=[];for await(let n of k(e,r))i.push(n.path);return i},re=te;var le=e=>{let t=normalize(e),r=basename(t),i=statSync(t);return {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:r,path:t}};function*R(e,{extensions:t,followSymlinks:r=!1,includeDirs:i=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a$2,maxDepth:l=Number.POSITIVE_INFINITY,skip:d}={}){if(g(e),l<0)return;let f=a$2?a$2.map(o=>typeof o=="string"?S(o):o):void 0,c=d?d.map(o=>typeof o=="string"?S(o):o):void 0;if(e=resolve(a(e)),i&&w(e,t,f,c)&&(yield le(e)),!(l<1||!w(e,void 0,void 0,c)))try{for(let o of readdirSync(e,{withFileTypes:!0})){let p=join(e,o.name);if(o.isSymbolicLink())if(r)p=realpathSync(p);else if(s&&w(p,t,f,c))yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:p};else continue;o.isSymbolicLink()||o.isDirectory()?yield*R(p,{extensions:t,followSymlinks:r,includeDirs:i,includeFiles:n,includeSymlinks:s,match:f,maxDepth:l-1,skip:c}):o.isFile()&&n&&w(p,t,f,c)&&(yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:p});}}catch(o){throw o instanceof a$1?o:new a$1(o,e)}}var me=(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},i=[];for(let n of R(e,r))i.push(n.path);return i},de=me;var we=async(e,t={})=>{if(typeof e!="string"&&!Array.isArray(e))throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=t.cwd?a(t.cwd):process.cwd();g(r);let i=resolve(r),{root:n}=parse(i),s=a(t.stopAt??n);g(s);let a$1=resolve(i,s),l=t.type??"file",d=typeof e=="string"?[e]:e;for(;i&&i!==a$1&&i!==n;){for await(let f of d){let c=isAbsolute(f)?f:resolve(i,f);try{let o=await stat(c);if(l==="file"&&o.isFile()||l==="directory"&&o.isDirectory())return c}catch{}}i=dirname(i);}},be=we;var ke=(e,t={})=>{if(typeof e!="string"&&!Array.isArray(e))throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=t.cwd?a(t.cwd):process.cwd();g(r);let i=resolve(r),{root:n}=parse(i),s=a(t.stopAt??n);g(s);let a$1=resolve(i,s),l=t.type??"file",d=typeof e=="string"?[e]:e;for(;i&&i!==a$1&&i!==n;){for(let f of d){let c=isAbsolute(f)?f:resolve(i,f);try{let o=statSync(c);if(l==="file"&&o.isFile()||l==="directory"&&o.isDirectory())return c}catch{}}i=dirname(i);}},Re=ke;async function Ee(e,t=0){g(e),e=a(e);try{return await access(e,t),!0}catch{return !1}}var b=Ee;function Pe(e,t=0){g(e),e=a(e);try{return accessSync(e,t),!0}catch{return !1}}var O=Pe;var Le={brotli:brotliDecompress,gzip:unzip,none:(e,t)=>{t(null,e);}},Ue=async(e,t)=>{if(g(e),e=a(e),!await b(e))throw new b$1(`unable to read the non-accessible file: ${e}`);if(!await b(e,4))throw new Error(`Unable to read the non-readable file: ${e}`);let{buffer:r,compression:i,encoding:n,flag:s}=t??{};return await readFile(e,s?{encoding:n,flag:s}:{encoding:n}).then(async a=>await new Promise((l,d)=>{Le[i??"none"](a,(f,c)=>{f?d(f):l(r?c:c.toString());});})).catch(a=>{throw a})},D=Ue;var Ve={brotli:brotliDecompressSync,gzip:unzipSync,none:e=>e},$e=(e,t)=>{if(g(e),e=a(e),!O(e))throw new b$1(`unable to read the non-accessible file: ${e}`);if(!O(e,4))throw new b$1(`invalid access to read file at: ${e}`);let{buffer:r,compression:i,encoding:n,flag:s}=t??{},a$1=readFileSync(e,s?{encoding:n,flag:s}:{encoding:n}),l=Ve[i??"none"](a$1);return r?l:l.toString()},v=$e;async function Ne(e,t,r){typeof t=="object"&&(r=t,t=void 0);let i=await D(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(i),{beforeParse:s,color:a$1}=r??{};return typeof s=="function"&&(n=s(n)),b$2(n,t,a(e),{color:a$1})}var Ce=Ne;function _e(e,t,r){typeof t=="object"&&(r=t,t=void 0);let i=v(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(i),{beforeParse:s,color:a$1}=r??{};return typeof s=="function"&&(n=s(n)),b$2(n,t,a(e),{color:a$1})}var Be=_e;var je=e=>{if(typeof e!="string"&&!(e instanceof ArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},A=je;var ze=new TextEncoder,Ke=e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return ze.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.")},W=Ke;var Ze=async(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},g(e),A(t),e=a(e);try{let i=await b(e,0);if(!i&&r.recursive){let a=dirname(e);await b(a,0)||await mkdir(a,{recursive:!0});}let n;await writeFile(`${e}.tmp`,W(t),{encoding:r.encoding,flag:r.flag}),i&&!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(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{await b(`${e}.tmp`)&&await unlink(`${e}.tmp`);}},V=Ze;var at=(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},g(e),A(t),e=a(e);try{let i=O(e,0);if(!i&&r.recursive){let a=dirname(e);O(a,0)||mkdirSync(a,{recursive:!0});}let n;writeFileSync(`${e}.tmp`,W(t),{encoding:r.encoding,flag:r.flag}),i&&!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(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{O(`${e}.tmp`)&&unlinkSync(`${e}.tmp`);}},$=at;var ft=/^(?:( )+|\t+)/,E="space",B="tab";function _(e,t){let r=new Map,i=0,n,s;for(let a of e.split(/\n/g)){if(!a)continue;let l,d,f,c,o,p=a.match(ft);if(p===null)i=0,n="";else {if(l=p[0].length,d=p[1]?E:B,t&&d===E&&l===1)continue;d!==n&&(i=0),n=d,f=1,c=0;let P=l-i;if(i=l,P===0)f=0,c=1;else {let j=P>0?P:-P;s=ct(d,j);}o=r.get(s),o=o===void 0?[1,0]:[o[0]+f,o[1]+c],r.set(s,o);}}return r}function ct(e,t){return (e===E?"s":"t")+String(t)}function lt(e){let r=e[0]==="s"?E:B,i=Number(e.slice(1));return {type:r,amount:i}}function mt(e){let t,r=0,i=0;for(let[n,[s,a]]of e)(s>r||s===r&&a>i)&&(r=s,i=a,t=n);return t}function dt(e,t){return (e===E?" ":" ").repeat(t)}function T(e){if(typeof e!="string")throw new TypeError("Expected a string");let t=_(e,!0);t.size===0&&(t=_(e,!1));let r=mt(t),i,n=0,s="";return r!==void 0&&({type:i,amount:n}=lt(r),s=dt(i,n)),{amount:n,type:i,indent:s}}var yt=async(e,t,r={})=>{let{detectIndent:i,indent:n,replacer:s,stringify:a=JSON.stringify,...l}={indent:" ",...r},d=n,f=`
10
- `;if(await b(e,4))try{let o=await readFile(e,"utf8");if(i){let{indent:p}=T(o);d=p;}f=o.endsWith(`
9
+ var j=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},g=j;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 Y=(e,t,i,r)=>t&&!t.some(o=>e.endsWith(o))||i&&!i.some(o=>o.test(e))?!1:!(r&&r.some(o=>o.test(e))),w=Y;var te=async e=>{let t=normalize(e),i=basename(t),r=await stat(t);return {isDirectory:r.isDirectory,isFile:r.isFile,isSymbolicLink:r.isSymbolicLink,name:i,path:t}};async function*x(e,{extensions:t,followSymlinks:i=!1,includeDirs:r=!0,includeFiles:o=!0,includeSymlinks:s=!0,match:f,maxDepth:l=Number.POSITIVE_INFINITY,skip:m}={}){if(g(e),l<0)return;let a$2=f?f.map(n=>typeof n=="string"?h(n):n):void 0,c=m?m.map(n=>typeof n=="string"?h(n):n):void 0;if(e=resolve(a(e)),r&&w(e,t,a$2,c)&&(yield await te(e)),!(l<1||!w(e,void 0,void 0,c)))try{for await(let n of await readdir(e,{withFileTypes:!0})){let p=join(e,n.name);if(n.isSymbolicLink())if(i)p=await realpath(p);else if(s&&w(p,t,a$2,c))yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:p};else continue;n.isSymbolicLink()||n.isDirectory()?yield*x(p,{extensions:t,followSymlinks:i,includeDirs:r,includeFiles:o,includeSymlinks:s,match:a$2,maxDepth:l-1,skip:c}):n.isFile()&&o&&w(p,t,a$2,c)&&(yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:p});}}catch(n){throw n instanceof a$1?n:new a$1(n,e)}}var re=async(e,t={})=>{let i={extensions:["js","mjs","cjs","ts"],...t},r=[];for await(let o of x(e,i))r.push(o.path);return r},ie=re;var de=e=>{let t=normalize(e),i=basename(t),r=statSync(t);return {isDirectory:r.isDirectory,isFile:r.isFile,isSymbolicLink:r.isSymbolicLink,name:i,path:t}};function*P(e,{extensions:t,followSymlinks:i=!1,includeDirs:r=!0,includeFiles:o=!0,includeSymlinks:s=!0,match:f,maxDepth:l=Number.POSITIVE_INFINITY,skip:m}={}){if(g(e),l<0)return;let a$2=f?f.map(n=>typeof n=="string"?h(n):n):void 0,c=m?m.map(n=>typeof n=="string"?h(n):n):void 0;if(e=resolve(a(e)),r&&w(e,t,a$2,c)&&(yield de(e)),!(l<1||!w(e,void 0,void 0,c)))try{for(let n of readdirSync(e,{withFileTypes:!0})){let p=join(e,n.name);if(n.isSymbolicLink())if(i)p=realpathSync(p);else if(s&&w(p,t,a$2,c))yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:p};else continue;n.isSymbolicLink()||n.isDirectory()?yield*P(p,{extensions:t,followSymlinks:i,includeDirs:r,includeFiles:o,includeSymlinks:s,match:a$2,maxDepth:l-1,skip:c}):n.isFile()&&o&&w(p,t,a$2,c)&&(yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:p});}}catch(n){throw n instanceof a$1?n:new a$1(n,e)}}var me=(e,t={})=>{let i={extensions:["js","mjs","cjs","ts"],...t},r=[];for(let o of P(e,i))r.push(o.path);return r},pe=me;var S=0,k=4,ye=2,ue=1,T=Symbol("findUpStop");var Se=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 i=t.cwd?a(t.cwd):process.cwd();g(i);let r=resolve(i),{root:o}=parse(r),s=a(t.stopAt??o);g(s);let f=resolve(r,s),l=t.type??"file",m=async function(a){return typeof e=="function"?[await e(a)]:typeof e=="string"?[e]:Array.isArray(e)?e:[e]};for(;r&&r!==f&&r!==o;){for await(let a of await m(r)){if(a===T)return;if(a===void 0)continue;let c=isAbsolute(a)?a:resolve(r,a);try{let n=await stat(c);if(l==="file"&&n.isFile()||l==="directory"&&n.isDirectory())return c}catch{}}r=dirname(r);}},be=Se;var ke=(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 i=t.cwd?a(t.cwd):process.cwd();g(i);let r=resolve(i),{root:o}=parse(r),s=a(t.stopAt??o);g(s);let f=resolve(r,s),l=t.type??"file",m=function(a){return typeof e=="function"?[e(a)]:typeof e=="string"?[e]:Array.isArray(e)?e:[e]};for(;r&&r!==f&&r!==o;){for(let a of m(r)){if(a===T)return;if(a===void 0)continue;let c=isAbsolute(a)?a:resolve(r,a);try{let n=statSync(c);if(l==="file"&&n.isFile()||l==="directory"&&n.isDirectory())return c}catch{}}r=dirname(r);}},Te=ke;async function Ae(e,t=0){g(e),e=a(e);try{return await access(e,t),!0}catch{return !1}}var O=Ae;function Ue(e,t=0){g(e),e=a(e);try{return accessSync(e,t),!0}catch{return !1}}var F=Ue;var Le={brotli:brotliDecompress,gzip:unzip,none:(e,t)=>{t(null,e);}},_e=async(e,t)=>{if(g(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:i,compression:r,encoding:o,flag:s}=t??{};return await readFile(e,s?{encoding:o,flag:s}:{encoding:o}).then(async f=>await new Promise((l,m)=>{Le[r??"none"](f,(a,c)=>{a?m(a):l(i?c:c.toString());});})).catch(f=>{throw f})},_=_e;var $e={brotli:brotliDecompressSync,gzip:unzipSync,none:e=>e},Ke=(e,t)=>{if(g(e),e=a(e),!F(e))throw new b(`unable to read the non-accessible file: ${e}`);if(!F(e,4))throw new b(`invalid access to read file at: ${e}`);let{buffer:i,compression:r,encoding:o,flag:s}=t??{},f=readFileSync(e,s?{encoding:o,flag:s}:{encoding:o}),l=$e[r??"none"](f);return i?l:l.toString()},v=Ke;async function Ce(e,t,i){typeof t=="object"&&(i=t,t=void 0);let r=await _(e,{buffer:!0,encoding:void 0}),o=new TextDecoder().decode(r),{beforeParse:s,color:f}=i??{};return typeof s=="function"&&(o=s(o)),b$1(o,t,a(e),{color:f})}var Me=Ce;function Be(e,t,i){typeof t=="object"&&(i=t,t=void 0);let r=v(e,{buffer:!0,encoding:void 0}),o=new TextDecoder().decode(r),{beforeParse:s,color:f}=i??{};return typeof s=="function"&&(o=s(o)),b$1(o,t,a(e),{color:f})}var je=Be;var ze=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=ze;var Ye=new TextEncoder,Xe=e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return Ye.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=Xe;var rt=async(e,t,i)=>{i={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...i},g(e),W(t),e=a(e);try{let r=await O(e,0);if(!r&&i.recursive){let f=dirname(e);await O(f,0)||await mkdir(f,{recursive:!0});}let o;await writeFile(`${e}.tmp`,I(t),{encoding:i.encoding,flag:i.flag}),r&&!i.overwrite&&(o=await stat(e),i.chown===void 0&&(i.chown={gid:o.gid,uid:o.uid}),await rename(e,`${e}.bak`));let s=`${e}.tmp`;if(i.chown)try{await chown(s,i.chown.uid,i.chown.gid);}catch{}await chmod(s,o&&!i.mode?o.mode:i.mode??438),await rename(s,e);}catch(r){throw new Error(`Failed to write file at: ${e} - ${r.message}`,{cause:r})}finally{await O(`${e}.tmp`)&&await unlink(`${e}.tmp`);}},N=rt;var lt=(e,t,i)=>{i={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...i},g(e),W(t),e=a(e);try{let r=F(e,0);if(!r&&i.recursive){let f=dirname(e);F(f,0)||mkdirSync(f,{recursive:!0});}let o;writeFileSync(`${e}.tmp`,I(t),{encoding:i.encoding,flag:i.flag}),r&&!i.overwrite&&(o=statSync(e),i.chown===void 0&&(i.chown={gid:o.gid,uid:o.uid}),renameSync(e,`${e}.bak`));let s=`${e}.tmp`;if(i.chown)try{chownSync(s,i.chown.uid,i.chown.gid);}catch{}chmodSync(s,o&&!i.mode?o.mode:i.mode??438),renameSync(s,e);}catch(r){throw new Error(`Failed to write file at: ${e} - ${r.message}`,{cause:r})}finally{F(`${e}.tmp`)&&unlinkSync(`${e}.tmp`);}},V=lt;var dt=/^(?:( )+|\t+)/,E="space",M="tab";function C(e,t){let i=new Map,r=0,o,s;for(let f of e.split(/\n/g)){if(!f)continue;let l,m,a,c,n,p=f.match(dt);if(p===null)r=0,o="";else {if(l=p[0].length,m=p[1]?E:M,t&&m===E&&l===1)continue;m!==o&&(r=0),o=m,a=1,c=0;let J=l-r;if(r=l,J===0)a=0,c=1;else {let B=J>0?J:-J;s=mt(m,B);}n=i.get(s),n=n===void 0?[1,0]:[n[0]+a,n[1]+c],i.set(s,n);}}return i}function mt(e,t){return (e===E?"s":"t")+String(t)}function pt(e){let i=e[0]==="s"?E:M,r=Number(e.slice(1));return {type:i,amount:r}}function yt(e){let t,i=0,r=0;for(let[o,[s,f]]of e)(s>i||s===i&&f>r)&&(i=s,r=f,t=o);return t}function ut(e,t){return (e===E?" ":" ").repeat(t)}function A(e){if(typeof e!="string")throw new TypeError("Expected a string");let t=C(e,!0);t.size===0&&(t=C(e,!1));let i=yt(t),r,o=0,s="";return i!==void 0&&({type:r,amount:o}=pt(i),s=ut(r,o)),{amount:o,type:r,indent:s}}var wt=async(e,t,i={})=>{let{detectIndent:r,indent:o,replacer:s,stringify:f=JSON.stringify,...l}={indent:" ",...i},m=o,a=`
10
+ `;if(await O(e,4))try{let n=await readFile(e,"utf8");if(r){let{indent:p}=A(n);m=p;}a=n.endsWith(`
11
11
  `)?`
12
- `:"";}catch(o){if(o.code!=="ENOENT")throw o}let c=a(t,s,d);await V(e,`${c}${f}`,l);},ut=yt;var wt=(e,t,r={})=>{let{detectIndent:i,indent:n,replacer:s,stringify:a=JSON.stringify,...l}={indent:" ",...r},d=n,f=`
13
- `;if(O(e,4))try{let o=readFileSync(e,"utf8");if(i){let{indent:p}=T(o);d=p;}f=o.endsWith(`
12
+ `:"";}catch(n){if(n.code!=="ENOENT")throw n}let c=f(t,s,m);await N(e,`${c}${a}`,l);},Ot=wt;var St=(e,t,i={})=>{let{detectIndent:r,indent:o,replacer:s,stringify:f=JSON.stringify,...l}={indent:" ",...i},m=o,a=`
13
+ `;if(F(e,4))try{let n=readFileSync(e,"utf8");if(r){let{indent:p}=A(n);m=p;}a=n.endsWith(`
14
14
  `)?`
15
- `:"";}catch(o){if(o.code!=="ENOENT")throw o}let c=a(t,s,d);$(e,`${c}${f}`,l);},bt=wt;
15
+ `:"";}catch(n){if(n.code!=="ENOENT")throw n}let c=f(t,s,m);V(e,`${c}${a}`,l);},bt=St;
16
16
 
17
- export { re as collect, de as collectSync, be as findUp, Re as findUpSync, b as isAccessible, O as isAccessibleSync, D as readFile, v as readFileSync, Ce as readJson, Be as readJsonSync, k as walk, R as walkSync, V as writeFile, $ as writeFileSync, ut as writeJson, bt as writeJsonSync };
17
+ export { T as FIND_UP_STOP, S as F_OK, k as R_OK, ye as W_OK, ue as X_OK, ie as collect, pe as collectSync, be as findUp, Te as findUpSync, O as isAccessible, F as isAccessibleSync, _ as readFile, v as readFileSync, Me as readJson, je as readJsonSync, x as walk, P as walkSync, N as writeFile, V as writeFileSync, Ot as writeJson, bt as writeJsonSync };
18
18
  //# sourceMappingURL=out.js.map
19
19
  //# 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/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/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"],"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","dirname","isAbsolute","parse","findUp","cwd","root","stopPath","stopAt","type","search","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","content","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","chmod","chown","mkdir","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","mkdirSync","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"],"mappings":"0HAMA,OAAS,WAAAA,EAAS,YAAAC,EAAU,QAAAC,MAAY,mBACxC,OAAS,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EAAUrB,CAAM,EAE7C,MAAMpB,EAAUzG,EAAM,GAAGwJ,CAAI,GAAGH,CAAe,GAAID,CAAY,CACnE,EAEOK,GAAQT,GE5Cf,OAAS,gBAAApE,OAAoB,UAU7B,IAAM8E,GAAgB,CAAC1J,EAAoBiF,EAAexD,EAA4B,CAAC,IAAY,CAC/F,GAAM,CAAE,aAAAqH,EAAc,OAAQG,EAAc,SAAAC,EAAU,UAAAC,EAAY,KAAK,UAAW,GAAGC,CAAa,EAAI,CAAE,OAAQ,IAAM,GAAG3H,CAAQ,EAE7HoG,EAASoB,EACTI,EAAkB;AAAA,EAEtB,GAAI5F,EAAiBzD,EAAM,CAAI,EAC3B,GAAI,CAEA,IAAMsJ,EAAO1E,GAAa5E,EAAM,MAAM,EAEtC,GAAI8I,EAAc,CAEd,GAAM,CAAE,OAAQS,CAAQ,EAAIT,EAAeQ,CAAI,EAE/CzB,EAAS0B,CACb,CAEAF,EAAkBC,EAAK,SAAS;AAAA,CAAI,EAAI;AAAA,EAAO,EAEnD,OAAShI,EAAY,CAEjB,GAAIA,EAAM,OAAS,SACf,MAAMA,CAEd,CAIJ,IAAMkI,EAAOL,EAAUlE,EAAMiE,EAAUrB,CAAM,EAE7CZ,EAAcjH,EAAM,GAAGwJ,CAAI,GAAGH,CAAe,GAAID,CAAY,CACjE,EAEOO,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","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, parse, resolve } from \"node:path\";\n\nimport type { FindUpOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: string[] | string,\n options: FindUpOptions = {},\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): Promise<string | undefined> => {\n if (typeof name !== \"string\" && !Array.isArray(name)) {\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\n assertValidFileOrDirectoryPath(stopPath);\n\n const stopAt = resolve(directory, stopPath);\n const type = options.type ?? \"file\";\n\n const search = typeof name === \"string\" ? [name] : name;\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 search) {\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 type { FindUpOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: string[] | string,\n options: FindUpOptions = {},\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): string | undefined => {\n if (typeof name !== \"string\" && !Array.isArray(name)) {\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 search = typeof name === \"string\" ? [name] : name;\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 search) {\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> | undefined> => {\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> | undefined => {\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 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"]}
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/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/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"],"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","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","content","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","chmod","chown","mkdir","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","mkdirSync","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"],"mappings":"0HAMA,OAAS,WAAAA,EAAS,YAAAC,EAAU,QAAAC,MAAY,mBACxC,OAAS,YAAAC,EAAU,QAAAC,EAAM,aAAAC,EAAW,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,IAAIC,CAAQ,GAAG,CACrC,EAEOC,EAAQH,ECzBf,IAAMI,EAAc,CAACC,EAAcC,EAAuBC,EAAkBC,IACpEF,GAAc,CAACA,EAAW,KAAMG,GAAuBJ,EAAK,SAASI,CAAS,CAAC,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ApE,OAAoB,UAU7B,IAAM8E,GAAgB,CAAChK,EAAoBuF,EAAe9D,EAA4B,CAAC,IAAY,CAC/F,GAAM,CAAE,aAAA2H,EAAc,OAAQG,EAAc,SAAAC,EAAU,UAAAC,EAAY,KAAK,UAAW,GAAGC,CAAa,EAAI,CAAE,OAAQ,IAAM,GAAGjI,CAAQ,EAE7H0G,EAASoB,EACTI,EAAkB;AAAA,EAEtB,GAAI5F,EAAiB/D,EAAM,CAAI,EAC3B,GAAI,CAEA,IAAM4J,EAAO1E,GAAalF,EAAM,MAAM,EAEtC,GAAIoJ,EAAc,CAEd,GAAM,CAAE,OAAQS,CAAQ,EAAIT,EAAeQ,CAAI,EAE/CzB,EAAS0B,CACb,CAEAF,EAAkBC,EAAK,SAAS;AAAA,CAAI,EAAI;AAAA,EAAO,EAEnD,OAAStI,EAAY,CAEjB,GAAIA,EAAM,OAAS,SACf,MAAMA,CAEd,CAIJ,IAAMwI,EAAOL,EAAUlE,EAAMiE,EAAUrB,CAAM,EAE7CZ,EAAcvH,EAAM,GAAG8J,CAAI,GAAGH,CAAe,GAAID,CAAY,CACjE,EAEOO,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","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> | undefined> => {\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> | undefined => {\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 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"]}
@@ -1,5 +1,11 @@
1
1
  import { Dirent } from 'node:fs';
2
2
 
3
+ declare const F_OK = 0;
4
+ declare const R_OK = 4;
5
+ declare const W_OK = 2;
6
+ declare const X_OK = 1;
7
+ declare const FIND_UP_STOP: unique symbol;
8
+
3
9
  type ColorizeMethod = (value: string) => string;
4
10
  interface WalkOptions {
5
11
  extensions?: string[];
@@ -62,5 +68,6 @@ type FindUpOptions = {
62
68
  stopAt?: URL | string;
63
69
  type?: "directory" | "file";
64
70
  };
71
+ type Match = string | typeof FIND_UP_STOP | undefined;
65
72
 
66
- export type { ContentType as C, FindUpOptions as F, JsonReviver as J, ReadFileOptions as R, WalkOptions as W, ReadJsonOptions as a, WalkEntry as b, WriteFileOptions as c, WriteJsonOptions as d, CodeFrameLocation as e, JsonReplacer as f, ReadFileEncoding as g, CodeFrameOptions as h };
73
+ export { type ContentType as C, type FindUpOptions as F, type JsonReviver as J, type Match as M, type ReadFileOptions as R, type WalkOptions as W, X_OK as X, type ReadJsonOptions as a, type WalkEntry as b, type WriteFileOptions as c, type WriteJsonOptions as d, F_OK as e, FIND_UP_STOP as f, R_OK as g, W_OK as h, type CodeFrameLocation as i, type JsonReplacer as j, type ReadFileEncoding as k, type CodeFrameOptions as l };
@@ -1,5 +1,11 @@
1
1
  import { Dirent } from 'node:fs';
2
2
 
3
+ declare const F_OK = 0;
4
+ declare const R_OK = 4;
5
+ declare const W_OK = 2;
6
+ declare const X_OK = 1;
7
+ declare const FIND_UP_STOP: unique symbol;
8
+
3
9
  type ColorizeMethod = (value: string) => string;
4
10
  interface WalkOptions {
5
11
  extensions?: string[];
@@ -62,5 +68,6 @@ type FindUpOptions = {
62
68
  stopAt?: URL | string;
63
69
  type?: "directory" | "file";
64
70
  };
71
+ type Match = string | typeof FIND_UP_STOP | undefined;
65
72
 
66
- export type { ContentType as C, FindUpOptions as F, JsonReviver as J, ReadFileOptions as R, WalkOptions as W, ReadJsonOptions as a, WalkEntry as b, WriteFileOptions as c, WriteJsonOptions as d, CodeFrameLocation as e, JsonReplacer as f, ReadFileEncoding as g, CodeFrameOptions as h };
73
+ export { type ContentType as C, type FindUpOptions as F, type JsonReviver as J, type Match as M, type ReadFileOptions as R, type WalkOptions as W, X_OK as X, type ReadJsonOptions as a, type WalkEntry as b, type WriteFileOptions as c, type WriteJsonOptions as d, F_OK as e, FIND_UP_STOP as f, R_OK as g, W_OK as h, type CodeFrameLocation as i, type JsonReplacer as j, type ReadFileEncoding as k, type CodeFrameOptions as l };
package/dist/utils.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { J as JSONError } from './json-error-UVjLdb7z.cjs';
2
2
  import { JsonValue } from 'type-fest';
3
- import { h as CodeFrameOptions, J as JsonReviver } from './types-9INKTu78.cjs';
3
+ import { l as CodeFrameOptions, J as JsonReviver } from './types-npDka8vJ.cjs';
4
4
  import 'node:fs';
5
5
 
6
6
  declare function parseJson<T = JsonValue>(string: string, filename?: string, options?: CodeFrameOptions): T;
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { J as JSONError } from './json-error-UVjLdb7z.js';
2
2
  import { JsonValue } from 'type-fest';
3
- import { h as CodeFrameOptions, J as JsonReviver } from './types-9INKTu78.js';
3
+ import { l as CodeFrameOptions, J as JsonReviver } from './types-npDka8vJ.js';
4
4
  import 'node:fs';
5
5
 
6
6
  declare function parseJson<T = JsonValue>(string: string, filename?: string, options?: CodeFrameOptions): T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/fs",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Human friendly file system utilities for Node.js",
5
5
  "keywords": [
6
6
  "anolilab",