@visulima/fs 1.8.0 → 1.9.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/index.cjs +36 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -5
- package/dist/index.d.ts +20 -5
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/{types-h2Rhl-Md.d.cts → types-HVB0D8On.d.cts} +8 -4
- package/dist/{types-h2Rhl-Md.d.ts → types-HVB0D8On.d.ts} +8 -4
- package/dist/utils.d.cts +2 -1
- package/dist/utils.d.ts +2 -1
- package/package.json +16 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { W as WalkOptions, E as EmptyDirOptions, M as Match, F as FindUpOptions, R as ReadFileOptions, C as ContentType, a as ReadJsonOptions, J as JsonReviver, b as
|
|
2
|
-
export {
|
|
1
|
+
import { W as WalkOptions, E as EmptyDirOptions, M as Match, F as FindUpOptions, R as ReadFileOptions, C as ContentType, a as ReadJsonOptions, J as JsonReviver, b as ReadYamlOptions, Y as YamlReviver, c as WalkEntry, d as WriteFileOptions, e as WriteJsonOptions, f as YamlReplacer } from './types-HVB0D8On.cjs';
|
|
2
|
+
export { k as CodeFrameLocation, h as FIND_UP_STOP, g as F_OK, l as JsonReplacer, i as R_OK, m as ReadFileEncoding, j as W_OK, X as X_OK } from './types-HVB0D8On.cjs';
|
|
3
3
|
import { JsonValue } from 'type-fest';
|
|
4
|
+
import { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToStringOptions } from 'yaml';
|
|
4
5
|
import 'node:fs';
|
|
5
6
|
|
|
6
7
|
declare const collect: (directory: string, options?: WalkOptions) => Promise<string[]>;
|
|
@@ -25,9 +26,9 @@ declare function isAccessible(path: URL | string, mode?: number): Promise<boolea
|
|
|
25
26
|
|
|
26
27
|
declare function isAccessibleSync(path: URL | string, mode?: number): boolean;
|
|
27
28
|
|
|
28
|
-
declare const readFile: <O extends ReadFileOptions<"brotli" | "gzip" | "none"> | undefined = undefined>(path: URL | string, options?: O) => Promise<ContentType<O
|
|
29
|
+
declare const readFile: <O extends ReadFileOptions<"brotli" | "gzip" | "none"> | undefined = undefined>(path: URL | string, options?: O) => Promise<ContentType<O>>;
|
|
29
30
|
|
|
30
|
-
declare const readFileSync: <O extends ReadFileOptions<"brotli" | "gzip" | "none"> | undefined = undefined>(path: URL | string, options?: O) => ContentType<O
|
|
31
|
+
declare const readFileSync: <O extends ReadFileOptions<"brotli" | "gzip" | "none"> | undefined = undefined>(path: URL | string, options?: O) => ContentType<O>;
|
|
31
32
|
|
|
32
33
|
declare function readJson<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): Promise<T>;
|
|
33
34
|
declare function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): Promise<T>;
|
|
@@ -35,6 +36,12 @@ declare function readJson<T extends JsonValue>(path: URL | string, reviver: Json
|
|
|
35
36
|
declare function readJsonSync<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): T;
|
|
36
37
|
declare function readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): T;
|
|
37
38
|
|
|
39
|
+
declare function readYaml<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): Promise<R>;
|
|
40
|
+
declare function readYaml<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): Promise<R>;
|
|
41
|
+
|
|
42
|
+
declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): R;
|
|
43
|
+
declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): R;
|
|
44
|
+
|
|
38
45
|
declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
|
|
39
46
|
|
|
40
47
|
declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
|
|
@@ -47,4 +54,12 @@ declare const writeJson: (path: URL | string, data: unknown, options?: WriteJson
|
|
|
47
54
|
|
|
48
55
|
declare const writeJsonSync: (path: URL | string, data: unknown, options?: WriteJsonOptions) => void;
|
|
49
56
|
|
|
50
|
-
|
|
57
|
+
type Options$1 = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions;
|
|
58
|
+
declare function writeYaml(path: URL | string, data: any, options?: Options$1): Promise<void>;
|
|
59
|
+
declare function writeYaml(path: URL | string, data: any, replacer?: YamlReplacer, options?: Options$1 | number | string): Promise<void>;
|
|
60
|
+
|
|
61
|
+
type Options = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions;
|
|
62
|
+
declare function writeYamlSync(path: URL | string, data: any, options?: Options): void;
|
|
63
|
+
declare function writeYamlSync(path: URL | string, data: any, replacer?: YamlReplacer, options?: Options | number | string): void;
|
|
64
|
+
|
|
65
|
+
export { CRLF, EOL, EmptyDirOptions, FindUpOptions, JsonReviver, LF, ReadFileOptions, ReadJsonOptions, WalkEntry, WalkOptions, WriteFileOptions, WriteJsonOptions, YamlReplacer, collect, collectSync, detect, emptyDir$1 as emptyDir, emptyDir as emptyDirSync, findUp, findUpSync, format, isAccessible, isAccessibleSync, readFile, readFileSync, readJson, readJsonSync, readYaml, readYamlSync, walk, walkSync, writeFile, writeFileSync, writeJson, writeJsonSync, writeYaml, writeYamlSync };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { W as WalkOptions, E as EmptyDirOptions, M as Match, F as FindUpOptions, R as ReadFileOptions, C as ContentType, a as ReadJsonOptions, J as JsonReviver, b as
|
|
2
|
-
export {
|
|
1
|
+
import { W as WalkOptions, E as EmptyDirOptions, M as Match, F as FindUpOptions, R as ReadFileOptions, C as ContentType, a as ReadJsonOptions, J as JsonReviver, b as ReadYamlOptions, Y as YamlReviver, c as WalkEntry, d as WriteFileOptions, e as WriteJsonOptions, f as YamlReplacer } from './types-HVB0D8On.js';
|
|
2
|
+
export { k as CodeFrameLocation, h as FIND_UP_STOP, g as F_OK, l as JsonReplacer, i as R_OK, m as ReadFileEncoding, j as W_OK, X as X_OK } from './types-HVB0D8On.js';
|
|
3
3
|
import { JsonValue } from 'type-fest';
|
|
4
|
+
import { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToStringOptions } from 'yaml';
|
|
4
5
|
import 'node:fs';
|
|
5
6
|
|
|
6
7
|
declare const collect: (directory: string, options?: WalkOptions) => Promise<string[]>;
|
|
@@ -25,9 +26,9 @@ declare function isAccessible(path: URL | string, mode?: number): Promise<boolea
|
|
|
25
26
|
|
|
26
27
|
declare function isAccessibleSync(path: URL | string, mode?: number): boolean;
|
|
27
28
|
|
|
28
|
-
declare const readFile: <O extends ReadFileOptions<"brotli" | "gzip" | "none"> | undefined = undefined>(path: URL | string, options?: O) => Promise<ContentType<O
|
|
29
|
+
declare const readFile: <O extends ReadFileOptions<"brotli" | "gzip" | "none"> | undefined = undefined>(path: URL | string, options?: O) => Promise<ContentType<O>>;
|
|
29
30
|
|
|
30
|
-
declare const readFileSync: <O extends ReadFileOptions<"brotli" | "gzip" | "none"> | undefined = undefined>(path: URL | string, options?: O) => ContentType<O
|
|
31
|
+
declare const readFileSync: <O extends ReadFileOptions<"brotli" | "gzip" | "none"> | undefined = undefined>(path: URL | string, options?: O) => ContentType<O>;
|
|
31
32
|
|
|
32
33
|
declare function readJson<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): Promise<T>;
|
|
33
34
|
declare function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): Promise<T>;
|
|
@@ -35,6 +36,12 @@ declare function readJson<T extends JsonValue>(path: URL | string, reviver: Json
|
|
|
35
36
|
declare function readJsonSync<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): T;
|
|
36
37
|
declare function readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): T;
|
|
37
38
|
|
|
39
|
+
declare function readYaml<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): Promise<R>;
|
|
40
|
+
declare function readYaml<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): Promise<R>;
|
|
41
|
+
|
|
42
|
+
declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): R;
|
|
43
|
+
declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): R;
|
|
44
|
+
|
|
38
45
|
declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
|
|
39
46
|
|
|
40
47
|
declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
|
|
@@ -47,4 +54,12 @@ declare const writeJson: (path: URL | string, data: unknown, options?: WriteJson
|
|
|
47
54
|
|
|
48
55
|
declare const writeJsonSync: (path: URL | string, data: unknown, options?: WriteJsonOptions) => void;
|
|
49
56
|
|
|
50
|
-
|
|
57
|
+
type Options$1 = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions;
|
|
58
|
+
declare function writeYaml(path: URL | string, data: any, options?: Options$1): Promise<void>;
|
|
59
|
+
declare function writeYaml(path: URL | string, data: any, replacer?: YamlReplacer, options?: Options$1 | number | string): Promise<void>;
|
|
60
|
+
|
|
61
|
+
type Options = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions;
|
|
62
|
+
declare function writeYamlSync(path: URL | string, data: any, options?: Options): void;
|
|
63
|
+
declare function writeYamlSync(path: URL | string, data: any, replacer?: YamlReplacer, options?: Options | number | string): void;
|
|
64
|
+
|
|
65
|
+
export { CRLF, EOL, EmptyDirOptions, FindUpOptions, JsonReviver, LF, ReadFileOptions, ReadJsonOptions, WalkEntry, WalkOptions, WriteFileOptions, WriteJsonOptions, YamlReplacer, collect, collectSync, detect, emptyDir$1 as emptyDir, emptyDir as emptyDirSync, findUp, findUpSync, format, isAccessible, isAccessibleSync, readFile, readFileSync, readJson, readJsonSync, readYaml, readYamlSync, walk, walkSync, writeFile, writeFileSync, writeJson, writeJsonSync, writeYaml, writeYamlSync };
|
package/dist/index.js
CHANGED
|
@@ -6,17 +6,18 @@ import { resolve, join, normalize, basename, parse, isAbsolute, dirname } from '
|
|
|
6
6
|
import { readdirSync, realpathSync, statSync, existsSync, mkdirSync, rmSync, accessSync, readFileSync, writeFileSync, renameSync, chownSync, chmodSync, unlinkSync } from 'node:fs';
|
|
7
7
|
import { platform } from 'node:process';
|
|
8
8
|
import { brotliDecompress, unzip, brotliDecompressSync, unzipSync } from 'node:zlib';
|
|
9
|
+
import { parse as parse$1, stringify } from 'yaml';
|
|
9
10
|
|
|
10
|
-
var
|
|
11
|
-
`,
|
|
12
|
-
`,
|
|
13
|
-
`;if(await O(
|
|
11
|
+
var Q=t=>{if(!t||!(t instanceof URL)&&typeof t!="string")throw new TypeError("Path must be a non-empty string or URL.")},u=Q;var Z=t=>{let e=t.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${e}$`)},b=Z;var tt=(t,e,r,o)=>e&&!e.some(n=>t.endsWith(n))||r&&!r.some(n=>n.test(t))?!1:!(o&&o.some(n=>n.test(t))),w=tt;var ft=async t=>{let e=normalize(t),r=basename(e),o=await stat(e);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:e}};async function*x(t,{extensions:e,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a$2,maxDepth:c=Number.POSITIVE_INFINITY,skip:y}={}){if(u(t),c<0)return;let f=a$2?a$2.map(i=>typeof i=="string"?b(i):i):void 0,m=y?y.map(i=>typeof i=="string"?b(i):i):void 0;if(t=resolve(a(t)),o&&w(t,e,f,m)&&(yield await ft(t)),!(c<1||!w(t,void 0,void 0,m)))try{for await(let i of await readdir(t,{withFileTypes:!0})){let g=join(t,i.name);if(i.isSymbolicLink())if(r)g=await realpath(g);else if(s&&w(g,e,f,m))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:g};else continue;i.isSymbolicLink()||i.isDirectory()?yield*x(g,{extensions:e,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:s,match:f,maxDepth:c-1,skip:m}):i.isFile()&&n&&w(g,e,f,m)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:g});}}catch(i){throw i instanceof a$1?i:new a$1(i,t)}}var ct=async(t,e={})=>{let r={extensions:["js","mjs","cjs","ts"],...e},o=[];for await(let n of x(t,r))o.push(n.path);return o},mt=ct;var Ot=t=>{let e=normalize(t),r=basename(e),o=statSync(e);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:e}};function*P(t,{extensions:e,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a$2,maxDepth:c=Number.POSITIVE_INFINITY,skip:y}={}){if(u(t),c<0)return;let f=a$2?a$2.map(i=>typeof i=="string"?b(i):i):void 0,m=y?y.map(i=>typeof i=="string"?b(i):i):void 0;if(t=resolve(a(t)),o&&w(t,e,f,m)&&(yield Ot(t)),!(c<1||!w(t,void 0,void 0,m)))try{for(let i of readdirSync(t,{withFileTypes:!0})){let g=join(t,i.name);if(i.isSymbolicLink())if(r)g=realpathSync(g);else if(s&&w(g,e,f,m))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:g};else continue;i.isSymbolicLink()||i.isDirectory()?yield*P(g,{extensions:e,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:s,match:f,maxDepth:c-1,skip:m}):i.isFile()&&n&&w(g,e,f,m)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:g});}}catch(i){throw i instanceof a$1?i:new a$1(i,t)}}var Rt=(t,e={})=>{let r={extensions:["js","mjs","cjs","ts"],...e},o=[];for(let n of P(t,r))o.push(n.path);return o},St=Rt;var S=0,k=4,ht=2,bt=1,T=Symbol("findUpStop");var Et=async(t,e)=>{if(u(t),!existsSync(t)){await mkdir(t,{recursive:!0});return}for await(let r of await readdir(t))await rm(join(a(t),r),{...e,force:!0,recursive:!0});},Lt=Et;var Yt=(t,e)=>{if(u(t),!existsSync(t)){mkdirSync(t,{recursive:!0});return}for(let r of readdirSync(t))rmSync(join(a(t),r),{...e,force:!0,recursive:!0});},Wt=Yt;var C=/\r?\n/g,N=`
|
|
12
|
+
`,W=`\r
|
|
13
|
+
`,_t=platform==="win32"?W:N,Nt=t=>{let e=t.match(C);if(!e||e.length===0)return null;let r=e.filter(n=>n===W).length,o=e.length-r;return r>o?W:N},Vt=(t,e)=>t.replaceAll(C,e);var Mt=async(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=e.cwd?a(e.cwd):process.cwd();u(r);let o=resolve(r),{root:n}=parse(o),s=a(e.stopAt??n);u(s);let a$1=resolve(o,s),c=e.type??"file",y=async function(f){return typeof t=="function"?[await t(f)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};for(;o&&o!==a$1&&o!==n;){for await(let f of await y(o)){if(f===T)return;if(f===void 0)continue;let m=isAbsolute(f)?f:resolve(o,f);try{let i=await stat(m);if(c==="file"&&i.isFile()||c==="directory"&&i.isDirectory())return m}catch{}}o=dirname(o);}},Bt=Mt;var qt=(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=e.cwd?a(e.cwd):process.cwd();u(r);let o=resolve(r),{root:n}=parse(o),s=a(e.stopAt??n);u(s);let a$1=resolve(o,s),c=e.type??"file",y=function(f){return typeof t=="function"?[t(f)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};for(;o&&o!==a$1&&o!==n;){for(let f of y(o)){if(f===T)return;if(f===void 0)continue;let m=isAbsolute(f)?f:resolve(o,f);try{let i=statSync(m);if(c==="file"&&i.isFile()||c==="directory"&&i.isDirectory())return m}catch{}}o=dirname(o);}},Qt=qt;async function te(t,e=0){u(t),t=a(t);try{return await access(t,e),!0}catch{return !1}}var O=te;function re(t,e=0){u(t),t=a(t);try{return accessSync(t,e),!0}catch{return !1}}var R=re;var se={brotli:brotliDecompress,gzip:unzip,none:(t,e)=>{e(null,t);}},ae=async(t,e)=>{if(u(t),t=a(t),!await O(t))throw new b$1(`unable to read the non-accessible file: ${t}`);if(!await O(t,4))throw new Error(`Unable to read the non-readable file: ${t}`);let{buffer:r,compression:o,encoding:n,flag:s}=e??{};return await readFile(t,s?{encoding:n,flag:s}:{encoding:n}).then(async a=>await new Promise((c,y)=>{se[o??"none"](a,(f,m)=>{f?y(f):c(r?m:m.toString());});})).catch(a=>{throw a})},E=ae;var pe={brotli:brotliDecompressSync,gzip:unzipSync,none:t=>t},le=(t,e)=>{if(u(t),t=a(t),!R(t))throw new b$1(`unable to read the non-accessible file: ${t}`);if(!R(t,4))throw new b$1(`invalid access to read file at: ${t}`);let{buffer:r,compression:o,encoding:n,flag:s}=e??{},a$1=readFileSync(t,s?{encoding:n,flag:s}:{encoding:n}),c=pe[o??"none"](a$1);return r?c:c.toString()},L=le;async function de(t,e,r){typeof e=="object"&&(r=e,e=void 0);let o=await E(t,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(o),{beforeParse:s,color:a$1}=r??{};return typeof s=="function"&&(n=s(n)),b$2(n,e,a(t),{color:a$1})}var ye=de;function ue(t,e,r){typeof e=="object"&&(r=e,e=void 0);let o=L(t,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(o),{beforeParse:s,color:a$1}=r??{};return typeof s=="function"&&(n=s(n)),b$2(n,e,a(t),{color:a$1})}var ge=ue;async function we(t,e,r){let{buffer:o,compression:n,encoding:s="utf8",flag:a,...c}=r??{},y=await E(t,{buffer:o,compression:n,encoding:s,flag:a});return typeof e=="function"?parse$1(y,e,c):parse$1(y,c)}var Oe=we;function Re(t,e,r){let{buffer:o,compression:n,encoding:s="utf8",flag:a,...c}=r??{},y=L(t,{buffer:o,compression:n,encoding:s,flag:a});return typeof e=="function"?parse$1(y,e,c):parse$1(y,c)}var Se=Re;var he=t=>{if(typeof t!="string"&&!(t instanceof ArrayBuffer)&&!ArrayBuffer.isView(t))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},I=he;var be=new TextEncoder,Fe=t=>{if(t instanceof Uint8Array)return t;if(typeof t=="string")return be.encode(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t)){let e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return new Uint8Array(e)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},_=Fe;var De=async(t,e,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},u(t),I(e),t=a(t);try{let o=await O(t,0);if(!o&&r.recursive){let a=dirname(t);await O(a,0)||await mkdir(a,{recursive:!0});}let n;await writeFile(`${t}.tmp`,_(e),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(n=await stat(t),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),await rename(t,`${t}.bak`));let s=`${t}.tmp`;if(r.chown)try{await chown(s,r.chown.uid,r.chown.gid);}catch{}await chmod(s,n&&!r.mode?n.mode:r.mode??438),await rename(s,t);}catch(o){throw new Error(`Failed to write file at: ${t} - ${o.message}`,{cause:o})}finally{await O(`${t}.tmp`)&&await unlink(`${t}.tmp`);}},U=De;var Ne=(t,e,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},u(t),I(e),t=a(t);try{let o=R(t,0);if(!o&&r.recursive){let a=dirname(t);R(a,0)||mkdirSync(a,{recursive:!0});}let n;writeFileSync(`${t}.tmp`,_(e),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(n=statSync(t),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),renameSync(t,`${t}.bak`));let s=`${t}.tmp`;if(r.chown)try{chownSync(s,r.chown.uid,r.chown.gid);}catch{}chmodSync(s,n&&!r.mode?n.mode:r.mode??438),renameSync(s,t);}catch(o){throw new Error(`Failed to write file at: ${t} - ${o.message}`,{cause:o})}finally{R(`${t}.tmp`)&&unlinkSync(`${t}.tmp`);}},D=Ne;var Ve=/^(?:( )+|\t+)/,v="space",X="tab";function j(t,e){let r=new Map,o=0,n,s;for(let a of t.split(/\n/g)){if(!a)continue;let c,y,f,m,i,g=a.match(Ve);if(g===null)o=0,n="";else {if(c=g[0].length,y=g[1]?v:X,e&&y===v&&c===1)continue;y!==n&&(o=0),n=y,f=1,m=0;let J=c-o;if(o=c,J===0)f=0,m=1;else {let q=J>0?J:-J;s=$e(y,q);}i=r.get(s),i=i===void 0?[1,0]:[i[0]+f,i[1]+m],r.set(s,i);}}return r}function $e(t,e){return (t===v?"s":"t")+String(e)}function Ce(t){let r=t[0]==="s"?v:X,o=Number(t.slice(1));return {type:r,amount:o}}function ze(t){let e,r=0,o=0;for(let[n,[s,a]]of t)(s>r||s===r&&a>o)&&(r=s,o=a,e=n);return e}function Ke(t,e){return (t===v?" ":" ").repeat(e)}function A(t){if(typeof t!="string")throw new TypeError("Expected a string");let e=j(t,!0);e.size===0&&(e=j(t,!1));let r=ze(e),o,n=0,s="";return r!==void 0&&({type:o,amount:n}=Ce(r),s=Ke(o,n)),{amount:n,type:o,indent:s}}var Be=async(t,e,r={})=>{let{detectIndent:o,indent:n,replacer:s,stringify:a=JSON.stringify,...c}={indent:" ",...r},y=n,f=`
|
|
14
|
+
`;if(await O(t,4))try{let i=await readFile(t,"utf8");if(o){let{indent:g}=A(i);y=g;}f=i.endsWith(`
|
|
14
15
|
`)?`
|
|
15
|
-
`:"";}catch(
|
|
16
|
-
`;if(
|
|
16
|
+
`:"";}catch(i){if(i.code!=="ENOENT")throw i}let m=a(e,s,y);await U(t,`${m}${f}`,c);},je=Be;var He=(t,e,r={})=>{let{detectIndent:o,indent:n,replacer:s,stringify:a=JSON.stringify,...c}={indent:" ",...r},y=n,f=`
|
|
17
|
+
`;if(R(t,4))try{let i=readFileSync(t,"utf8");if(o){let{indent:g}=A(i);y=g;}f=i.endsWith(`
|
|
17
18
|
`)?`
|
|
18
|
-
`:"";}catch(
|
|
19
|
+
`:"";}catch(i){if(i.code!=="ENOENT")throw i}let m=a(e,s,y);D(t,`${m}${f}`,c);},Ge=He;async function qe(t,e,r,o){let n=typeof r=="function"||Array.isArray(r)?stringify(e,r,o):stringify(e,r);await U(t,n);}var Qe=qe;function Ze(t,e,r,o){let n=typeof r=="function"||Array.isArray(r)?stringify(e,r,o):stringify(e,r);D(t,n);}var tr=Ze;
|
|
19
20
|
|
|
20
|
-
export {
|
|
21
|
+
export { W as CRLF, _t as EOL, T as FIND_UP_STOP, S as F_OK, N as LF, k as R_OK, ht as W_OK, bt as X_OK, mt as collect, St as collectSync, Nt as detect, Lt as emptyDir, Wt as emptyDirSync, Bt as findUp, Qt as findUpSync, Vt as format, O as isAccessible, R as isAccessibleSync, E as readFile, L as readFileSync, ye as readJson, ge as readJsonSync, Oe as readYaml, Se as readYamlSync, x as walk, P as walkSync, U as writeFile, D as writeFileSync, je as writeJson, Ge as writeJsonSync, Qe as writeYaml, tr as writeYamlSync };
|
|
21
22
|
//# sourceMappingURL=out.js.map
|
|
22
23
|
//# sourceMappingURL=index.js.map
|