@visulima/fs 1.10.0 → 1.11.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 +7 -0
- package/dist/error.cjs +5 -4
- package/dist/error.cjs.map +1 -1
- package/dist/error.d.cts +7 -1
- package/dist/error.d.ts +7 -1
- package/dist/error.js +2 -2
- package/dist/error.js.map +1 -1
- package/dist/index.cjs +46 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/package.json +6 -1
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { a as a$
|
|
2
|
-
import { a, b as b$1 } from './chunk-4WZBYISP.js';
|
|
1
|
+
import { a as a$2, b } from './chunk-3EHZOWRU.js';
|
|
2
|
+
import { a as a$1, b as b$1 } from './chunk-4WZBYISP.js';
|
|
3
3
|
import './chunk-UPN3Y5W3.js';
|
|
4
|
-
import { readdir, realpath, stat, mkdir, rm, access, readFile, unlink,
|
|
5
|
-
import { resolve, join, normalize, basename, parse, isAbsolute
|
|
6
|
-
import { readdirSync, realpathSync, statSync, existsSync, mkdirSync, rmSync, accessSync, readFileSync, unlinkSync,
|
|
4
|
+
import { readdir, realpath, stat, mkdir, rm, lstat, writeFile, link, access, readFile, unlink, rename, chown, chmod } from 'node:fs/promises';
|
|
5
|
+
import { resolve, join, normalize, basename, dirname, parse, isAbsolute } from 'node:path';
|
|
6
|
+
import { readdirSync, realpathSync, statSync, existsSync, mkdirSync, rmSync, lstatSync, writeFileSync, linkSync, accessSync, readFileSync, unlinkSync, renameSync, chownSync, chmodSync } from 'node:fs';
|
|
7
7
|
import { platform } from 'node:process';
|
|
8
8
|
import { brotliDecompress, unzip, brotliDecompressSync, unzipSync } from 'node:zlib';
|
|
9
9
|
import { parse as parse$1, stringify } from 'yaml';
|
|
10
10
|
|
|
11
|
-
var
|
|
12
|
-
`,
|
|
13
|
-
`,
|
|
14
|
-
`;if(await
|
|
11
|
+
var st=t=>{if(!t||!(t instanceof URL)&&typeof t!="string")throw new TypeError("Path must be a non-empty string or URL.")},a=st;var at=t=>{let e=t.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${e}$`)},F=at;var ft=(t,e,r,o)=>e&&!e.some(i=>t.endsWith(i))||r&&!r.some(i=>i.test(t))?!1:!(o&&o.some(i=>i.test(t))),w=ft;var gt=async t=>{let e=normalize(t),r=basename(e),o=await stat(e);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:e}};async function*P(t,{extensions:e,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:i=!0,includeSymlinks:s=!0,match:m,maxDepth:d=Number.POSITIVE_INFINITY,skip:u}={}){if(a(t),d<0)return;let p=m?m.map(n=>typeof n=="string"?F(n):n):void 0,y=u?u.map(n=>typeof n=="string"?F(n):n):void 0;if(t=resolve(a$1(t)),o&&w(t,e,p,y)&&(yield await gt(t)),!(d<1||!w(t,void 0,void 0,y)))try{for await(let n of await readdir(t,{withFileTypes:!0})){let g=join(t,n.name);if(n.isSymbolicLink())if(r)g=await realpath(g);else if(s&&w(g,e,p,y))yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:g};else continue;n.isSymbolicLink()||n.isDirectory()?yield*P(g,{extensions:e,followSymlinks:r,includeDirs:o,includeFiles:i,includeSymlinks:s,match:p,maxDepth:d-1,skip:y}):n.isFile()&&i&&w(g,e,p,y)&&(yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:g});}}catch(n){throw n instanceof a$2?n:new a$2(n,t)}}var wt=async(t,e={})=>{let r={extensions:["js","mjs","cjs","ts"],...e},o=[];for await(let i of P(t,r))o.push(i.path);return o},Ot=wt;var kt=t=>{let e=normalize(t),r=basename(e),o=statSync(e);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:e}};function*k(t,{extensions:e,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:i=!0,includeSymlinks:s=!0,match:m,maxDepth:d=Number.POSITIVE_INFINITY,skip:u}={}){if(a(t),d<0)return;let p=m?m.map(n=>typeof n=="string"?F(n):n):void 0,y=u?u.map(n=>typeof n=="string"?F(n):n):void 0;if(t=resolve(a$1(t)),o&&w(t,e,p,y)&&(yield kt(t)),!(d<1||!w(t,void 0,void 0,y)))try{for(let n of readdirSync(t,{withFileTypes:!0})){let g=join(t,n.name);if(n.isSymbolicLink())if(r)g=realpathSync(g);else if(s&&w(g,e,p,y))yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:g};else continue;n.isSymbolicLink()||n.isDirectory()?yield*k(g,{extensions:e,followSymlinks:r,includeDirs:o,includeFiles:i,includeSymlinks:s,match:p,maxDepth:d-1,skip:y}):n.isFile()&&i&&w(g,e,p,y)&&(yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:g});}}catch(n){throw n instanceof a$2?n:new a$2(n,t)}}var Et=(t,e={})=>{let r={extensions:["js","mjs","cjs","ts"],...e},o=[];for(let i of k(t,r))o.push(i.path);return o},Dt=Et;var h=0,E=4,Lt=2,Tt=1,D=Symbol("findUpStop");var Yt=async(t,e)=>{if(a(t),!existsSync(t)){await mkdir(t,{recursive:!0});return}for await(let r of await readdir(t))await rm(join(a$1(t),r),{...e,force:!0,recursive:!0});},Nt=Yt;var zt=(t,e)=>{if(a(t),!existsSync(t)){mkdirSync(t,{recursive:!0});return}for(let r of readdirSync(t))rmSync(join(a$1(t),r),{...e,force:!0,recursive:!0});},Kt=zt;var O=t=>{if(t.isFile())return "file";if(t.isDirectory())return "dir";if(t.isSymbolicLink())return "symlink"};var Bt=async t=>{a(t);try{let e=await lstat(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${O(e)}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{await mkdir(t,{recursive:!0});}catch(e){if(e.code!=="EEXIST")throw e;let r=await lstat(t);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${O(r)}'`)}},L=Bt;var Xt=t=>{a(t);try{let e=lstatSync(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${O(e)}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{mkdirSync(t,{recursive:!0});}catch(e){if(e.code!=="EEXIST")throw e;let r=lstatSync(t);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${O(r)}'`)}},T=Xt;var Qt=async t=>{a(t);try{let e=await lstat(t);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${O(e)}'`)}catch(e){if(e.code==="ENOENT"){await L(dirname(a$1(t))),await writeFile(t,new Uint8Array);return}throw e}},Zt=Qt;var oe=t=>{a(t);try{let e=lstatSync(t);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${O(e)}'`)}catch(e){if(e.code==="ENOENT"){T(dirname(a$1(t))),writeFileSync(t,new Uint8Array);return}throw e}},ie=oe;var ne=(t,e)=>!!e.ino&&!!e.dev&&e.ino===t.ino&&e.dev===t.dev,V=ne;var fe=async(t,e)=>{a(t),a(e);let r;try{r=await lstat(e);}catch{}let o;try{o=await lstat(t);}catch(i){throw i.message=i.message.replace("lstat","ensureLink"),i}r&&V(o,r)||(await L(dirname(a$1(e))),await link(t,e));},ce=fe;var le=(t,e)=>{a(t),a(e);let r;try{r=lstatSync(e);}catch{}let o;try{o=lstatSync(t);}catch(i){throw i.message=i.message.replace("lstat","ensureLink"),i}r&&V(o,r)||(T(dirname(a$1(e))),linkSync(t,e));},de=le;var G=/\r?\n/g,z=`
|
|
12
|
+
`,_=`\r
|
|
13
|
+
`,ue=platform==="win32"?_:z,ge=t=>{let e=t.match(G);if(!e||e.length===0)return null;let r=e.filter(i=>i===_).length,o=e.length-r;return r>o?_:z},we=(t,e)=>t.replaceAll(G,e);var xe=async(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=e.cwd?a$1(e.cwd):process.cwd();a(r);let o=resolve(r),{root:i}=parse(o),s=a$1(e.stopAt??i);a(s);let m=resolve(o,s),d=e.type??"file",u=async function(p){return typeof t=="function"?[await t(p)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};for(;o&&o!==m&&o!==i;){for await(let p of await u(o)){if(p===D)return;if(p===void 0)continue;let y=isAbsolute(p)?p:resolve(o,p);try{let n=await stat(y);if(d==="file"&&n.isFile()||d==="directory"&&n.isDirectory())return y}catch{}}o=dirname(o);}},Fe=xe;var De=(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=e.cwd?a$1(e.cwd):process.cwd();a(r);let o=resolve(r),{root:i}=parse(o),s=a$1(e.stopAt??i);a(s);let m=resolve(o,s),d=e.type??"file",u=function(p){return typeof t=="function"?[t(p)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};for(;o&&o!==m&&o!==i;){for(let p of u(o)){if(p===D)return;if(p===void 0)continue;let y=isAbsolute(p)?p:resolve(o,p);try{let n=statSync(y);if(d==="file"&&n.isFile()||d==="directory"&&n.isDirectory())return y}catch{}}o=dirname(o);}},Le=De;async function ve(t,e=0){a(t),t=a$1(t);try{return await access(t,e),!0}catch{return !1}}var R=ve;function Ae(t,e=0){a(t),t=a$1(t);try{return accessSync(t,e),!0}catch{return !1}}var S=Ae;var Ne={brotli:brotliDecompress,gzip:unzip,none:(t,e)=>{e(null,t);}},We=async(t,e)=>{if(a(t),t=a$1(t),!await R(t))throw new b(`unable to read the non-accessible file: ${t}`);if(!await R(t,4))throw new Error(`Unable to read the non-readable file: ${t}`);let{buffer:r,compression:o,encoding:i,flag:s}=e??{};return await readFile(t,s?{encoding:i,flag:s}:{encoding:i}).then(async m=>await new Promise((d,u)=>{Ne[o??"none"](m,(p,y)=>{p?u(p):d(r?y:y.toString());});})).catch(m=>{throw m})},v=We;var Ce={brotli:brotliDecompressSync,gzip:unzipSync,none:t=>t},ze=(t,e)=>{if(a(t),t=a$1(t),!S(t))throw new b(`unable to read the non-accessible file: ${t}`);if(!S(t,4))throw new b(`invalid access to read file at: ${t}`);let{buffer:r,compression:o,encoding:i,flag:s}=e??{},m=readFileSync(t,s?{encoding:i,flag:s}:{encoding:i}),d=Ce[o??"none"](m);return r?d:d.toString()},U=ze;async function Ke(t,e,r){typeof e=="object"&&(r=e,e=void 0);let o=await v(t,{buffer:!0,encoding:void 0}),i=new TextDecoder().decode(o),{beforeParse:s,color:m}=r??{};return typeof s=="function"&&(i=s(i)),b$1(i,e,a$1(t),{color:m})}var Me=Ke;function Be(t,e,r){typeof e=="object"&&(r=e,e=void 0);let o=U(t,{buffer:!0,encoding:void 0}),i=new TextDecoder().decode(o),{beforeParse:s,color:m}=r??{};return typeof s=="function"&&(i=s(i)),b$1(i,e,a$1(t),{color:m})}var je=Be;async function Xe(t,e,r){let{buffer:o,compression:i,encoding:s="utf8",flag:m,...d}=r??{},u=await v(t,{buffer:o,compression:i,encoding:s,flag:m});return typeof e=="function"?parse$1(u,e,d):parse$1(u,d)}var He=Xe;function Ge(t,e,r){let{buffer:o,compression:i,encoding:s="utf8",flag:m,...d}=r??{},u=U(t,{buffer:o,compression:i,encoding:s,flag:m});return typeof e=="function"?parse$1(u,e,d):parse$1(u,d)}var qe=Ge;var tr=async(t,e={})=>{a(t);try{await unlink(t);}catch{}try{await rm(t,{force:!0,maxRetries:e?.maxRetries,recursive:!0,retryDelay:e?.retryDelay});}catch{}},er=tr;var ir=(t,e={})=>{a(t);try{unlinkSync(t);}catch{}try{rmSync(t,{force:!0,maxRetries:e?.maxRetries,recursive:!0,retryDelay:e?.retryDelay});}catch{}},nr=ir;var sr=t=>{if(typeof t!="string"&&!(t instanceof ArrayBuffer)&&!ArrayBuffer.isView(t))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},$=sr;var ar=new TextEncoder,fr=t=>{if(t instanceof Uint8Array)return t;if(typeof t=="string")return ar.encode(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t)){let e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return new Uint8Array(e)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},C=fr;var gr=async(t,e,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},a(t),$(e),t=a$1(t);try{let o=await R(t,0);if(!o&&r.recursive){let m=dirname(t);await R(m,0)||await mkdir(m,{recursive:!0});}let i;await writeFile(`${t}.tmp`,C(e),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(i=await stat(t),r.chown===void 0&&(r.chown={gid:i.gid,uid:i.uid}),await rename(t,`${t}.bak`));let s=`${t}.tmp`;if(r.chown)try{await chown(s,r.chown.uid,r.chown.gid);}catch{}await chmod(s,i&&!r.mode?i.mode:r.mode??438),await rename(s,t);}catch(o){throw new Error(`Failed to write file at: ${t} - ${o.message}`,{cause:o})}finally{await R(`${t}.tmp`)&&await unlink(`${t}.tmp`);}},A=gr;var br=(t,e,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},a(t),$(e),t=a$1(t);try{let o=S(t,0);if(!o&&r.recursive){let m=dirname(t);S(m,0)||mkdirSync(m,{recursive:!0});}let i;writeFileSync(`${t}.tmp`,C(e),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(i=statSync(t),r.chown===void 0&&(r.chown={gid:i.gid,uid:i.uid}),renameSync(t,`${t}.bak`));let s=`${t}.tmp`;if(r.chown)try{chownSync(s,r.chown.uid,r.chown.gid);}catch{}chmodSync(s,i&&!r.mode?i.mode:r.mode??438),renameSync(s,t);}catch(o){throw new Error(`Failed to write file at: ${t} - ${o.message}`,{cause:o})}finally{S(`${t}.tmp`)&&unlinkSync(`${t}.tmp`);}},I=br;var Pr=/^(?:( )+|\t+)/,J="space",rt="tab";function et(t,e){let r=new Map,o=0,i,s;for(let m of t.split(/\n/g)){if(!m)continue;let d,u,p,y,n,g=m.match(Pr);if(g===null)o=0,i="";else {if(d=g[0].length,u=g[1]?J:rt,e&&u===J&&d===1)continue;u!==i&&(o=0),i=u,p=1,y=0;let N=d-o;if(o=d,N===0)p=0,y=1;else {let nt=N>0?N:-N;s=kr(u,nt);}n=r.get(s),n=n===void 0?[1,0]:[n[0]+p,n[1]+y],r.set(s,n);}}return r}function kr(t,e){return (t===J?"s":"t")+String(e)}function Er(t){let r=t[0]==="s"?J:rt,o=Number(t.slice(1));return {type:r,amount:o}}function Dr(t){let e,r=0,o=0;for(let[i,[s,m]]of t)(s>r||s===r&&m>o)&&(r=s,o=m,e=i);return e}function Lr(t,e){return (t===J?" ":" ").repeat(e)}function Y(t){if(typeof t!="string")throw new TypeError("Expected a string");let e=et(t,!0);e.size===0&&(e=et(t,!1));let r=Dr(e),o,i=0,s="";return r!==void 0&&({type:o,amount:i}=Er(r),s=Lr(o,i)),{amount:i,type:o,indent:s}}var vr=async(t,e,r={})=>{let{detectIndent:o,indent:i,replacer:s,stringify:m=JSON.stringify,...d}={indent:" ",...r},u=i,p=`
|
|
14
|
+
`;if(await R(t,4))try{let n=await readFile(t,"utf8");if(o){let{indent:g}=Y(n);u=g;}p=n.endsWith(`
|
|
15
15
|
`)?`
|
|
16
|
-
`:"";}catch(
|
|
17
|
-
`;if(
|
|
16
|
+
`:"";}catch(n){if(n.code!=="ENOENT")throw n}let y=m(e,s,u);await A(t,`${y}${p}`,d);},Ur=vr;var Ir=(t,e,r={})=>{let{detectIndent:o,indent:i,replacer:s,stringify:m=JSON.stringify,...d}={indent:" ",...r},u=i,p=`
|
|
17
|
+
`;if(S(t,4))try{let n=readFileSync(t,"utf8");if(o){let{indent:g}=Y(n);u=g;}p=n.endsWith(`
|
|
18
18
|
`)?`
|
|
19
|
-
`:"";}catch(
|
|
19
|
+
`:"";}catch(n){if(n.code!=="ENOENT")throw n}let y=m(e,s,u);I(t,`${y}${p}`,d);},Jr=Ir;async function Yr(t,e,r,o){let i=typeof r=="function"||Array.isArray(r)?stringify(e,r,o):stringify(e,r);await A(t,i);}var Nr=Yr;function Wr(t,e,r,o){let i=typeof r=="function"||Array.isArray(r)?stringify(e,r,o):stringify(e,r);I(t,i);}var Vr=Wr;
|
|
20
20
|
|
|
21
|
-
export {
|
|
21
|
+
export { _ as CRLF, ue as EOL, D as FIND_UP_STOP, h as F_OK, z as LF, E as R_OK, Lt as W_OK, Tt as X_OK, Ot as collect, Dt as collectSync, ge as detect, Nt as emptyDir, Kt as emptyDirSync, L as ensureDir, T as ensureDirSync, Zt as ensureFile, ie as ensureFileSync, ce as ensureLink, de as ensureLinkSync, Fe as findUp, Le as findUpSync, we as format, R as isAccessible, S as isAccessibleSync, v as readFile, U as readFileSync, Me as readJson, je as readJsonSync, He as readYaml, qe as readYamlSync, er as remove, nr as removeSync, P as walk, k as walkSync, A as writeFile, I as writeFileSync, Ur as writeJson, Jr as writeJsonSync, Nr as writeYaml, Vr as writeYamlSync };
|
|
22
22
|
//# sourceMappingURL=out.js.map
|
|
23
23
|
//# sourceMappingURL=index.js.map
|