@visulima/fs 5.0.0-alpha.1 → 5.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/CHANGELOG.md +177 -0
  2. package/LICENSE.md +157 -128
  3. package/dist/eol.d.ts +6 -35
  4. package/dist/error.d.ts +43 -7
  5. package/dist/error.js +1 -1
  6. package/dist/glob-parent.d.ts +5 -0
  7. package/dist/glob-parent.js +90 -0
  8. package/dist/glob.d.ts +5 -0
  9. package/dist/glob.js +2 -0
  10. package/dist/index.d.ts +81 -36
  11. package/dist/index.js +32 -27
  12. package/dist/ini.d.ts +10 -0
  13. package/dist/ini.js +4 -0
  14. package/dist/is-glob.d.ts +5 -0
  15. package/dist/is-glob.js +9 -0
  16. package/dist/json5.d.ts +12 -0
  17. package/dist/json5.js +4 -0
  18. package/dist/jsonc.d.ts +10 -0
  19. package/dist/jsonc.js +4 -0
  20. package/dist/match.d.ts +5 -0
  21. package/dist/match.js +15 -0
  22. package/dist/packem_shared/{WalkError-DUdQd6FT.js → WalkError-DER5A43G.js} +1 -1
  23. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +5 -0
  24. package/dist/packem_shared/build-rm-options-Cl3VDY4O.js +12 -0
  25. package/dist/packem_shared/{collect-DcBwsYYd.js → collect-CqQ3eVab.js} +1 -1
  26. package/dist/packem_shared/{collectSync-Bkjf9Dbm.js → collectSync-noE08NNv.js} +1 -1
  27. package/dist/packem_shared/{emptyDir-CYB5Tict.js → emptyDir-DnwENOaV.js} +5 -2
  28. package/dist/packem_shared/{emptyDirSync-BD8-1Ytl.js → emptyDirSync-6WiHBo8a.js} +3 -1
  29. package/dist/packem_shared/{ensureDir-C_kuQ5Ik.js → ensureDir-DNlPftys.js} +2 -2
  30. package/dist/packem_shared/{ensureDirSync-CI5g-uBI.js → ensureDirSync-DcPZFMy5.js} +2 -2
  31. package/dist/packem_shared/{ensureFile-BUtXGlGT.js → ensureFile-BRQpUOUM.js} +2 -2
  32. package/dist/packem_shared/{ensureFileSync-C8hASR-1.js → ensureFileSync-SBY7A9-C.js} +2 -2
  33. package/dist/packem_shared/{ensureLink-BPnAG5-P.js → ensureLink-DJQeauEn.js} +4 -3
  34. package/dist/packem_shared/{ensureLinkSync-B-Z7X0ub.js → ensureLinkSync-D9RVAglV.js} +4 -3
  35. package/dist/packem_shared/{ensureSymlink-U5B6J0BN.js → ensureSymlink-CoRYDRwr.js} +10 -3
  36. package/dist/packem_shared/{ensureSymlinkSync-DHnZj-9F.js → ensureSymlinkSync-CFimFlgh.js} +10 -3
  37. package/dist/packem_shared/{findUp-BSnyGqer.js → findUp-YcNLKdfV.js} +3 -4
  38. package/dist/packem_shared/{findUpSync-jRHbSCMV.js → findUpSync-BfA5fheN.js} +1 -3
  39. package/dist/packem_shared/glob-DY8l7izD.js +5 -0
  40. package/dist/packem_shared/glob-sync.d-BlGjS68e.d.ts +4 -0
  41. package/dist/packem_shared/globSync-5P2KJf_g.js +5 -0
  42. package/dist/packem_shared/index-C8W8sfzP.js +830 -0
  43. package/dist/packem_shared/index-bhgnhm4u.js +167 -0
  44. package/dist/packem_shared/index-xe4o3cYi.js +1784 -0
  45. package/dist/packem_shared/{parseJson-C8xb-3LR.js → indexToLineColumn-BUb0GPKl-BF770uX7.js} +8 -68
  46. package/dist/packem_shared/ini-preserve-Dq_Q_Jgb.js +251 -0
  47. package/dist/packem_shared/{isFsCaseSensitive-D-ayleCy.js → isFsCaseSensitive-DunL7Iry.js} +6 -6
  48. package/dist/packem_shared/json-error.d-DgKaeuIf.d.ts +10 -0
  49. package/dist/packem_shared/jsonc-merge-C6jWcfWh.js +72 -0
  50. package/dist/packem_shared/parseJson-BIp89Xjo.js +63 -0
  51. package/dist/packem_shared/{readFileSync-6GEIrOnl.js → readFileSync-gm9yfIhh.js} +2 -1
  52. package/dist/packem_shared/readIni-CJ2xfpjB.js +10 -0
  53. package/dist/packem_shared/readIniSync-9LUjaSSp.js +10 -0
  54. package/dist/packem_shared/{readJson-vddQ97Ll.js → readJson-C_rwm-wq.js} +1 -1
  55. package/dist/packem_shared/readJson5-mBoTZppy.js +15 -0
  56. package/dist/packem_shared/readJson5Sync-8WS2yUok.js +15 -0
  57. package/dist/packem_shared/{readJsonSync-DzeAdYZl.js → readJsonSync-BMEmCcJ6.js} +2 -2
  58. package/dist/packem_shared/readJsonc-j-OS-APg.js +28 -0
  59. package/dist/packem_shared/readJsoncSync-Aw6EMlWO.js +16 -0
  60. package/dist/packem_shared/readToml-B2MHaSes.js +9 -0
  61. package/dist/packem_shared/readTomlSync-DNbK8NEb.js +9 -0
  62. package/dist/packem_shared/{readYamlSync-DMV4U-gi.js → readYamlSync-BKX-PAfq.js} +1 -1
  63. package/dist/packem_shared/{remove-_oDY3uKo.js → remove-C8_gl3jF.js} +2 -1
  64. package/dist/packem_shared/{removeSync-DETRj7Qn.js → removeSync-BJR_wTwN.js} +2 -1
  65. package/dist/packem_shared/{sanitize-lOzE6k2A.js → sanitize-BZoLN9Fg.js} +3 -3
  66. package/dist/packem_shared/types.d-CYpAhWov.d.ts +145 -0
  67. package/dist/packem_shared/{walk-BhTbpr3y.js → walk-CSZgCuDx.js} +19 -10
  68. package/dist/packem_shared/{walkSync-DDBq95s8.js → walkSync-C4Cy28xb.js} +25 -16
  69. package/dist/packem_shared/{writeFile-DSHERs0Z.js → writeFile-B8HX0JIQ.js} +1 -3
  70. package/dist/packem_shared/{writeFileSync-CJp1kXQR.js → writeFileSync-DB8vv8xR.js} +1 -3
  71. package/dist/packem_shared/writeIni-i55QrL8y.js +65 -0
  72. package/dist/packem_shared/writeIniSync-CLqJE5t3.js +64 -0
  73. package/dist/packem_shared/{writeJson-C0OfLDbe.js → writeJson-Bo7C2UHw.js} +1 -1
  74. package/dist/packem_shared/writeJson5-vVmHUQOd.js +53 -0
  75. package/dist/packem_shared/writeJson5Sync-oJ546h5k.js +53 -0
  76. package/dist/packem_shared/{writeJsonSync-Cs21FE7v.js → writeJsonSync-BKZ_9Acr.js} +1 -1
  77. package/dist/packem_shared/writeJsonc-BufH_oC5.js +60 -0
  78. package/dist/packem_shared/writeJsoncSync-DB9be1YL.js +59 -0
  79. package/dist/packem_shared/writeToml-DgTW_-7F.js +8 -0
  80. package/dist/packem_shared/writeTomlSync-DiBiE9ja.js +8 -0
  81. package/dist/packem_shared/{writeYaml-n4xzYN9a.js → writeYaml-BWCOome-.js} +3 -3
  82. package/dist/packem_shared/{writeYamlSync-DnOEnP10.js → writeYamlSync-DBVnXmuY.js} +3 -3
  83. package/dist/size.d.ts +10 -254
  84. package/dist/size.js +6 -4
  85. package/dist/toml.d.ts +9 -0
  86. package/dist/toml.js +4 -0
  87. package/dist/utils.d.ts +15 -6
  88. package/dist/utils.js +1 -1
  89. package/dist/yaml.d.ts +14 -5
  90. package/dist/yaml.js +3 -3
  91. package/package.json +60 -6
  92. package/dist/constants.d.ts +0 -42
  93. package/dist/ensure/ensure-dir-sync.d.ts +0 -14
  94. package/dist/ensure/ensure-dir.d.ts +0 -14
  95. package/dist/ensure/ensure-file-sync.d.ts +0 -15
  96. package/dist/ensure/ensure-file.d.ts +0 -27
  97. package/dist/ensure/ensure-link-sync.d.ts +0 -16
  98. package/dist/ensure/ensure-link.d.ts +0 -16
  99. package/dist/ensure/ensure-symlink-sync.d.ts +0 -23
  100. package/dist/ensure/ensure-symlink.d.ts +0 -23
  101. package/dist/ensure/utils/get-file-info-type.d.ts +0 -7
  102. package/dist/ensure/utils/is-stats-identical.d.ts +0 -3
  103. package/dist/ensure/utils/resolve-symlink-target.d.ts +0 -2
  104. package/dist/error/already-exists-error.d.ts +0 -39
  105. package/dist/error/directory-error.d.ts +0 -47
  106. package/dist/error/json-error.d.ts +0 -52
  107. package/dist/error/not-empty-error.d.ts +0 -51
  108. package/dist/error/not-found-error.d.ts +0 -44
  109. package/dist/error/permission-error.d.ts +0 -45
  110. package/dist/error/walk-error.d.ts +0 -51
  111. package/dist/find/collect-sync.d.ts +0 -31
  112. package/dist/find/collect.d.ts +0 -35
  113. package/dist/find/find-up-sync.d.ts +0 -42
  114. package/dist/find/find-up.d.ts +0 -46
  115. package/dist/find/utils/glob-to-regexp.d.ts +0 -2
  116. package/dist/find/utils/walk-include.d.ts +0 -2
  117. package/dist/find/walk-sync.d.ts +0 -34
  118. package/dist/find/walk.d.ts +0 -37
  119. package/dist/is-accessible-sync.d.ts +0 -3
  120. package/dist/is-accessible.d.ts +0 -29
  121. package/dist/move/index.d.ts +0 -68
  122. package/dist/move/types.d.ts +0 -36
  123. package/dist/move/utils/internal-move-file-sync.d.ts +0 -3
  124. package/dist/move/utils/internal-move-file.d.ts +0 -3
  125. package/dist/move/utils/validate-same-directory.d.ts +0 -2
  126. package/dist/read/read-file-sync.d.ts +0 -37
  127. package/dist/read/read-file.d.ts +0 -41
  128. package/dist/read/read-json-sync.d.ts +0 -5
  129. package/dist/read/read-json.d.ts +0 -5
  130. package/dist/read/read-yaml-sync.d.ts +0 -4
  131. package/dist/read/read-yaml.d.ts +0 -4
  132. package/dist/remove/empty-dir-sync.d.ts +0 -23
  133. package/dist/remove/empty-dir.d.ts +0 -28
  134. package/dist/remove/remove-sync.d.ts +0 -27
  135. package/dist/remove/remove.d.ts +0 -32
  136. package/dist/sanitize.d.ts +0 -31
  137. package/dist/types.d.ts +0 -304
  138. package/dist/utils/assert-valid-file-contents.d.ts +0 -27
  139. package/dist/utils/assert-valid-file-or-directory-path.d.ts +0 -26
  140. package/dist/utils/parse-json.d.ts +0 -5
  141. package/dist/utils/strip-json-comments.d.ts +0 -44
  142. package/dist/write/utils/to-uint-8-array.d.ts +0 -2
  143. package/dist/write/write-file-sync.d.ts +0 -30
  144. package/dist/write/write-file.d.ts +0 -30
  145. package/dist/write/write-json-sync.d.ts +0 -29
  146. package/dist/write/write-json.d.ts +0 -30
  147. package/dist/write/write-yaml-sync.d.ts +0 -4
  148. package/dist/write/write-yaml.d.ts +0 -4
@@ -0,0 +1,9 @@
1
+ import { parse } from 'smol-toml';
2
+ import readFile from './readFile-Iz7kvCCk.js';
3
+
4
+ const readToml = async (path, options) => {
5
+ const content = await readFile(path, { encoding: "utf8", ...options });
6
+ return parse(content);
7
+ };
8
+
9
+ export { readToml as default };
@@ -0,0 +1,9 @@
1
+ import { parse } from 'smol-toml';
2
+ import readFileSync from './readFileSync-gm9yfIhh.js';
3
+
4
+ const readTomlSync = (path, options) => {
5
+ const content = readFileSync(path, { encoding: "utf8", ...options });
6
+ return parse(content);
7
+ };
8
+
9
+ export { readTomlSync as default };
@@ -1,5 +1,5 @@
1
1
  import { parse } from 'yaml';
2
- import readFileSync from './readFileSync-6GEIrOnl.js';
2
+ import readFileSync from './readFileSync-gm9yfIhh.js';
3
3
 
4
4
  function readYamlSync(path, reviver, options) {
5
5
  const { buffer, compression, encoding = "utf8", flag, ...parseOptions } = options ?? {};
@@ -22,6 +22,7 @@ const {
22
22
  rm
23
23
  } = __cjs_getBuiltinModule("node:fs/promises");
24
24
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
25
+ import { b as buildRmOptions } from './build-rm-options-Cl3VDY4O.js';
25
26
 
26
27
  const remove = async (path, options = {}) => {
27
28
  assertValidFileOrDirectoryPath(path);
@@ -30,7 +31,7 @@ const remove = async (path, options = {}) => {
30
31
  } catch {
31
32
  }
32
33
  try {
33
- await rm(path, { force: true, maxRetries: options?.maxRetries, recursive: true, retryDelay: options?.retryDelay });
34
+ await rm(path, buildRmOptions(options));
34
35
  } catch {
35
36
  }
36
37
  };
@@ -22,6 +22,7 @@ const {
22
22
  rmSync
23
23
  } = __cjs_getBuiltinModule("node:fs");
24
24
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
25
+ import { b as buildRmOptions } from './build-rm-options-Cl3VDY4O.js';
25
26
 
26
27
  const removeSync = (path, options = {}) => {
27
28
  assertValidFileOrDirectoryPath(path);
@@ -30,7 +31,7 @@ const removeSync = (path, options = {}) => {
30
31
  } catch {
31
32
  }
32
33
  try {
33
- rmSync(path, { force: true, maxRetries: options?.maxRetries, recursive: true, retryDelay: options?.retryDelay });
34
+ rmSync(path, buildRmOptions(options));
34
35
  } catch {
35
36
  }
36
37
  };
@@ -73,7 +73,7 @@ const cleanWindowsName = (name) => {
73
73
  const extension = name.slice(lastDotIndex);
74
74
  let cleanedBaseName = baseName;
75
75
  while (cleanedBaseName.length > 0) {
76
- const char = cleanedBaseName[cleanedBaseName.length - 1];
76
+ const char = cleanedBaseName.at(-1);
77
77
  if (char === void 0 || !TRIM_CHARS.has(char)) {
78
78
  break;
79
79
  }
@@ -86,7 +86,7 @@ const cleanWindowsName = (name) => {
86
86
  }
87
87
  let cleaned = name;
88
88
  while (cleaned.length > 0) {
89
- const char = cleaned[cleaned.length - 1];
89
+ const char = cleaned.at(-1);
90
90
  if (char === void 0 || !TRIM_CHARS.has(char)) {
91
91
  break;
92
92
  }
@@ -104,7 +104,7 @@ const isWindowsReservedName = (name) => {
104
104
  }
105
105
  let trimmed = name;
106
106
  while (trimmed.length > 0) {
107
- const char = trimmed[trimmed.length - 1];
107
+ const char = trimmed.at(-1);
108
108
  if (char === void 0 || !TRIM_CHARS.has(char)) {
109
109
  break;
110
110
  }
@@ -0,0 +1,145 @@
1
+ import { PathLike, Dirent } from 'node:fs';
2
+ import { GlobOptions as GlobOptions$1 } from 'tinyglobby';
3
+ import { DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions, CreateNodeOptions, ToStringOptions } from './options';
4
+ declare const F_OK: number;
5
+ declare const R_OK: number;
6
+ declare const W_OK: number;
7
+ declare const X_OK: number;
8
+ declare const FIND_UP_STOP: symbol;
9
+ type ColorizeMethod = (value: string) => string;
10
+ type JsoncParseOptions = {
11
+ allowEmptyContent?: boolean;
12
+ allowTrailingComma?: boolean;
13
+ disallowComments?: boolean;
14
+ };
15
+ type JsoncFormattingOptions = {
16
+ eol?: string;
17
+ insertFinalNewline?: boolean;
18
+ insertSpaces?: boolean;
19
+ keepLines?: boolean;
20
+ tabSize?: number;
21
+ };
22
+ type IniEncodeOptions = {
23
+ align?: boolean;
24
+ bracketedArray?: boolean;
25
+ newline?: boolean;
26
+ platform?: string;
27
+ section?: string;
28
+ sort?: boolean;
29
+ whitespace?: boolean;
30
+ };
31
+ type Json5Replacer = (number | string)[] | ((this: unknown, key: string, value: unknown) => unknown) | null;
32
+ type GlobOptions = Omit<GlobOptions$1, "patterns">;
33
+ interface WalkOptions {
34
+ extensions?: string[];
35
+ followSymlinks?: boolean;
36
+ includeDirs?: boolean;
37
+ includeFiles?: boolean;
38
+ includeSymlinks?: boolean;
39
+ match?: (RegExp | string)[];
40
+ maxDepth?: number;
41
+ skip?: (RegExp | string)[];
42
+ }
43
+ interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
44
+ path: string;
45
+ }
46
+ type CompressionType = "brotli" | "gzip" | "none";
47
+ type ReadFileEncoding = "ascii" | "base64" | "base64url" | "hex" | "latin1" | "ucs-2" | "ucs2" | "utf-8" | "utf-16le" | "utf8" | "utf16le";
48
+ type ReadFileOptions<C> = {
49
+ buffer?: boolean;
50
+ compression?: C;
51
+ encoding?: ReadFileEncoding;
52
+ flag?: number | string;
53
+ };
54
+ type ContentType<O = undefined> = O extends {
55
+ buffer: true;
56
+ } ? Buffer : string;
57
+ type JsonReviver = Parameters<(typeof JSON)["parse"]>["1"];
58
+ type CodeFrameLocation = {
59
+ column?: number;
60
+ line: number;
61
+ };
62
+ type CodeFrameOptions = {
63
+ color?: {
64
+ gutter?: ColorizeMethod;
65
+ marker?: ColorizeMethod;
66
+ message?: ColorizeMethod;
67
+ };
68
+ };
69
+ type ReadJsonOptions = CodeFrameOptions & {
70
+ beforeParse?: (source: string) => string;
71
+ };
72
+ type WriteFileOptions = {
73
+ chown?: {
74
+ gid: number;
75
+ uid: number;
76
+ };
77
+ encoding?: BufferEncoding | null;
78
+ flag?: string;
79
+ mode?: number;
80
+ overwrite?: boolean;
81
+ recursive?: boolean;
82
+ };
83
+ type JsonReplacer = (number | string)[] | ((this: unknown, key: string, value: unknown) => unknown) | null;
84
+ type YamlReplacer = JsonReplacer;
85
+ type WriteJsonOptions = WriteFileOptions & {
86
+ detectIndent?: boolean;
87
+ indent?: number | string;
88
+ replacer?: JsonReplacer;
89
+ stringify?: (data: unknown, replacer: JsonReplacer, space: number | string | undefined) => string;
90
+ };
91
+ type FindUpOptions = {
92
+ allowSymlinks?: boolean;
93
+ cwd?: URL | string;
94
+ stopAt?: URL | string;
95
+ type?: "directory" | "file";
96
+ };
97
+ type FindUpNameFnResult = PathLike | Promise<PathLike | typeof FIND_UP_STOP> | typeof FIND_UP_STOP | undefined;
98
+ type FindUpName = string[] | string | ((directory: string) => FindUpNameFnResult);
99
+ type FindUpNameSyncFnResult = PathLike | typeof FIND_UP_STOP | undefined;
100
+ type FindUpNameSync = string[] | string | ((directory: string) => FindUpNameSyncFnResult);
101
+ type RetryOptions = {
102
+ maxRetries?: number;
103
+ retryDelay?: number;
104
+ };
105
+ type ReadYamlOptions<C> = DocumentOptions & ParseOptions & ReadFileOptions<C> & SchemaOptions & ToJSOptions;
106
+ type YamlReviver = (key: unknown, value: unknown) => unknown;
107
+ type WriteYamlExtras = {
108
+ replacer?: JsonReplacer;
109
+ space?: number | string;
110
+ };
111
+ type WriteYamlOptions = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions & WriteFileOptions & WriteYamlExtras;
112
+ type ReadTomlOptions<C> = ReadFileOptions<C>;
113
+ type WriteTomlOptions = WriteFileOptions;
114
+ type ReadJsoncExtras = {
115
+ beforeParse?: (source: string) => string;
116
+ };
117
+ type ReadJsoncOptions<C> = CodeFrameOptions & JsoncParseOptions & ReadFileOptions<C> & ReadJsoncExtras;
118
+ type WriteJsoncOptions = WriteFileOptions & {
119
+ detectIndent?: boolean;
120
+ formattingOptions?: JsoncFormattingOptions;
121
+ indent?: number | string;
122
+ preserveComments?: boolean;
123
+ replacer?: JsonReplacer;
124
+ };
125
+ type Json5Reviver = (this: unknown, key: string, value: unknown) => unknown;
126
+ type ReadJson5Extras = {
127
+ beforeParse?: (source: string) => string;
128
+ };
129
+ type ReadJson5Options<C> = CodeFrameOptions & ReadFileOptions<C> & ReadJson5Extras;
130
+ type WriteJson5Options = WriteFileOptions & {
131
+ detectIndent?: boolean;
132
+ indent?: number | string;
133
+ quote?: string;
134
+ replacer?: Json5Replacer;
135
+ };
136
+ type ReadIniOptions<C> = ReadFileOptions<C> & {
137
+ bracketedArray?: boolean;
138
+ };
139
+ type IniLineEnding = "\n" | "\r\n";
140
+ type WriteIniExtras = {
141
+ eol?: IniLineEnding;
142
+ preserveStyle?: boolean;
143
+ };
144
+ type WriteIniOptions = IniEncodeOptions & WriteFileOptions & WriteIniExtras;
145
+ export { CodeFrameLocation as A, FIND_UP_STOP as B, CodeFrameOptions as C, F_OK as D, FindUpNameFnResult as E, FindUpName as F, GlobOptions as G, FindUpNameSyncFnResult as H, IniEncodeOptions as I, JsonReviver as J, R_OK as K, ReadFileEncoding as L, W_OK as M, ReadYamlOptions as R, WriteYamlOptions as W, X_OK as X, YamlReviver as Y, CompressionType as a, JsonReplacer as b, YamlReplacer as c, ReadJsoncOptions as d, WriteJsoncOptions as e, JsoncFormattingOptions as f, JsoncParseOptions as g, ReadTomlOptions as h, WriteTomlOptions as i, ReadJson5Options as j, Json5Reviver as k, WriteJson5Options as l, Json5Replacer as m, ReadIniOptions as n, WriteIniOptions as o, IniLineEnding as p, WalkOptions as q, FindUpOptions as r, FindUpNameSync as s, WalkEntry as t, ReadFileOptions as u, ContentType as v, ReadJsonOptions as w, RetryOptions as x, WriteFileOptions as y, WriteJsonOptions as z };
@@ -24,7 +24,7 @@ const {
24
24
  } = __cjs_getBuiltinModule("node:fs/promises");
25
25
  import { resolve, join, normalize, basename } from '@visulima/path';
26
26
  import { toPath } from '@visulima/path/utils';
27
- import WalkError from './WalkError-DUdQd6FT.js';
27
+ import WalkError from './WalkError-DER5A43G.js';
28
28
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
29
29
  import { g as globToRegExp, w as walkInclude } from './walk-include-CZco7BvN.js';
30
30
 
@@ -54,9 +54,16 @@ async function* walk(directory, {
54
54
  if (maxDepth < 0) {
55
55
  return;
56
56
  }
57
- const mappedMatch = match ? match.map((pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern) : void 0;
58
- const mappedSkip = skip ? skip.map((pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern) : void 0;
59
- directory = resolve(toPath(directory));
57
+ const mappedMatch = match ? match.map(
58
+ // eslint-disable-next-line no-confusing-arrow
59
+ (pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern
60
+ ) : void 0;
61
+ const mappedSkip = skip ? skip.map(
62
+ // eslint-disable-next-line no-confusing-arrow
63
+ (pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern
64
+ ) : void 0;
65
+ const resolvedDirectory = resolve(toPath(directory));
66
+ directory = resolvedDirectory;
60
67
  if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {
61
68
  yield await _createWalkEntry(directory);
62
69
  }
@@ -64,26 +71,28 @@ async function* walk(directory, {
64
71
  return;
65
72
  }
66
73
  try {
67
- for await (const entry of await readdir(directory, {
74
+ const entries = await readdir(directory, {
68
75
  withFileTypes: true
69
- })) {
76
+ });
77
+ for (const entry of entries) {
70
78
  let path = join(directory, entry.name);
71
79
  if (entry.isSymbolicLink()) {
72
80
  if (followSymlinks) {
73
81
  path = await realpath(path);
74
82
  } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
75
83
  yield {
76
- isDirectory: entry.isDirectory,
77
- isFile: entry.isFile,
78
- isSymbolicLink: entry.isSymbolicLink,
84
+ isDirectory: () => entry.isDirectory(),
85
+ isFile: () => entry.isFile(),
86
+ isSymbolicLink: () => entry.isSymbolicLink(),
79
87
  name: entry.name,
80
88
  path
81
89
  };
90
+ continue;
82
91
  } else {
83
92
  continue;
84
93
  }
85
94
  }
86
- if (entry.isSymbolicLink() || entry.isDirectory()) {
95
+ if (entry.isDirectory()) {
87
96
  yield* walk(path, {
88
97
  extensions,
89
98
  followSymlinks,
@@ -24,7 +24,7 @@ const {
24
24
  } = __cjs_getBuiltinModule("node:fs");
25
25
  import { resolve, join, normalize, basename } from '@visulima/path';
26
26
  import { toPath } from '@visulima/path/utils';
27
- import WalkError from './WalkError-DUdQd6FT.js';
27
+ import WalkError from './WalkError-DER5A43G.js';
28
28
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
29
29
  import { g as globToRegExp, w as walkInclude } from './walk-include-CZco7BvN.js';
30
30
 
@@ -32,9 +32,9 @@ const _createWalkEntry = (path) => {
32
32
  const normalizePath = normalize(path);
33
33
  const info = statSync(normalizePath);
34
34
  return {
35
- isDirectory: info.isDirectory,
36
- isFile: info.isFile,
37
- isSymbolicLink: info.isSymbolicLink,
35
+ isDirectory: () => info.isDirectory(),
36
+ isFile: () => info.isFile(),
37
+ isSymbolicLink: () => info.isSymbolicLink(),
38
38
  name: basename(normalizePath),
39
39
  path: normalizePath
40
40
  };
@@ -53,9 +53,16 @@ function* walkSync(directory, {
53
53
  if (maxDepth < 0) {
54
54
  return;
55
55
  }
56
- const mappedMatch = match ? match.map((pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern) : void 0;
57
- const mappedSkip = skip ? skip.map((pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern) : void 0;
58
- directory = resolve(toPath(directory));
56
+ const mappedMatch = match ? match.map(
57
+ // eslint-disable-next-line no-confusing-arrow
58
+ (pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern
59
+ ) : void 0;
60
+ const mappedSkip = skip ? skip.map(
61
+ // eslint-disable-next-line no-confusing-arrow
62
+ (pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern
63
+ ) : void 0;
64
+ const resolvedDirectory = resolve(toPath(directory));
65
+ directory = resolvedDirectory;
59
66
  if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {
60
67
  yield _createWalkEntry(directory);
61
68
  }
@@ -63,26 +70,28 @@ function* walkSync(directory, {
63
70
  return;
64
71
  }
65
72
  try {
66
- for (const entry of readdirSync(directory, {
73
+ const entries = readdirSync(directory, {
67
74
  withFileTypes: true
68
- })) {
75
+ });
76
+ for (const entry of entries) {
69
77
  let path = join(directory, entry.name);
70
78
  if (entry.isSymbolicLink()) {
71
79
  if (followSymlinks) {
72
80
  path = realpathSync(path);
73
81
  } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
74
82
  yield {
75
- isDirectory: entry.isDirectory,
76
- isFile: entry.isFile,
77
- isSymbolicLink: entry.isSymbolicLink,
83
+ isDirectory: () => entry.isDirectory(),
84
+ isFile: () => entry.isFile(),
85
+ isSymbolicLink: () => entry.isSymbolicLink(),
78
86
  name: entry.name,
79
87
  path: normalize(path)
80
88
  };
89
+ continue;
81
90
  } else {
82
91
  continue;
83
92
  }
84
93
  }
85
- if (entry.isSymbolicLink() || entry.isDirectory()) {
94
+ if (entry.isDirectory()) {
86
95
  yield* walkSync(path, {
87
96
  extensions,
88
97
  followSymlinks,
@@ -95,9 +104,9 @@ function* walkSync(directory, {
95
104
  });
96
105
  } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
97
106
  yield {
98
- isDirectory: entry.isDirectory,
99
- isFile: entry.isFile,
100
- isSymbolicLink: entry.isSymbolicLink,
107
+ isDirectory: () => entry.isDirectory(),
108
+ isFile: () => entry.isFile(),
109
+ isSymbolicLink: () => entry.isSymbolicLink(),
101
110
  name: entry.name,
102
111
  path: normalize(path)
103
112
  };
@@ -58,9 +58,7 @@ const writeFile = async (path, content, options) => {
58
58
  await writeFile$1(temporaryPath, toUint8Array(content), { encoding: options.encoding, flag: options.flag });
59
59
  if (pathExists && !options.overwrite) {
60
60
  stat$1 = await stat(path);
61
- if (options.chown === void 0) {
62
- options.chown = { gid: stat$1.gid, uid: stat$1.uid };
63
- }
61
+ options.chown ??= { gid: stat$1.gid, uid: stat$1.uid };
64
62
  await rename(path, `${path}.bak`);
65
63
  }
66
64
  if (options.chown) {
@@ -58,9 +58,7 @@ const writeFileSync = (path, content, options) => {
58
58
  writeFileSync$1(temporaryPath, toUint8Array(content), { encoding: options.encoding, flag: options.flag });
59
59
  if (pathExists && !options.overwrite) {
60
60
  stat = statSync(path);
61
- if (options.chown === void 0) {
62
- options.chown = { gid: stat.gid, uid: stat.uid };
63
- }
61
+ options.chown ??= { gid: stat.gid, uid: stat.uid };
64
62
  renameSync(path, `${path}.bak`);
65
63
  }
66
64
  if (options.chown) {
@@ -0,0 +1,65 @@
1
+ import { createRequire as __cjs_createRequire } from "node:module";
2
+
3
+ const __cjs_require = __cjs_createRequire(import.meta.url);
4
+
5
+ const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
+
7
+ const __cjs_getBuiltinModule = (module) => {
8
+ // Check if we're in Node.js and version supports getBuiltinModule
9
+ if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
+ const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
+ // Node.js 20.16.0+ and 22.3.0+
12
+ if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
+ return __cjs_getProcess.getBuiltinModule(module);
14
+ }
15
+ }
16
+ // Fallback to createRequire
17
+ return __cjs_require(module);
18
+ };
19
+
20
+ const {
21
+ readFile
22
+ } = __cjs_getBuiltinModule("node:fs/promises");
23
+ import { parse, stringify } from 'ini';
24
+ import { R_OK } from './F_OK-MldBaGxb.js';
25
+ import isAccessible from './isAccessible-DuVrTNFV.js';
26
+ import { d as detectIniStyle, m as mergeIniPreservingLines } from './ini-preserve-Dq_Q_Jgb.js';
27
+ import writeFile from './writeFile-B8HX0JIQ.js';
28
+
29
+ const writeIni = async (path, data, options = {}) => {
30
+ const { eol, preserveStyle = true, whitespace, ...rest } = options;
31
+ const { align, bracketedArray, newline, platform, section, sort, ...writeOptions } = rest;
32
+ let resolvedEol = eol;
33
+ let resolvedWhitespace = whitespace;
34
+ let existingText;
35
+ let oldData;
36
+ const accessible = preserveStyle ? await isAccessible(path, R_OK) : false;
37
+ if (accessible) {
38
+ try {
39
+ existingText = await readFile(path, "utf8");
40
+ oldData = parse(existingText, { bracketedArray: bracketedArray ?? true });
41
+ const detected = detectIniStyle(existingText);
42
+ resolvedEol ??= detected.eol;
43
+ resolvedWhitespace ??= detected.whitespace;
44
+ } catch (error) {
45
+ if (error.code !== "ENOENT") {
46
+ throw error;
47
+ }
48
+ }
49
+ }
50
+ const encodeOptions = { align, bracketedArray, newline, platform, section, sort, whitespace: resolvedWhitespace };
51
+ const freshStringify = (value, sectionName) => stringify(value, sectionName === void 0 ? encodeOptions : { ...encodeOptions, section: sectionName });
52
+ let output;
53
+ if (existingText !== void 0 && oldData) {
54
+ output = mergeIniPreservingLines(existingText, oldData, data, freshStringify, {
55
+ eol: resolvedEol ?? "\n"});
56
+ } else {
57
+ output = freshStringify(data, section);
58
+ if (resolvedEol === "\r\n") {
59
+ output = output.replaceAll(/\r?\n/g, "\r\n");
60
+ }
61
+ }
62
+ await writeFile(path, output, writeOptions);
63
+ };
64
+
65
+ export { writeIni as default };
@@ -0,0 +1,64 @@
1
+ import { createRequire as __cjs_createRequire } from "node:module";
2
+
3
+ const __cjs_require = __cjs_createRequire(import.meta.url);
4
+
5
+ const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
+
7
+ const __cjs_getBuiltinModule = (module) => {
8
+ // Check if we're in Node.js and version supports getBuiltinModule
9
+ if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
+ const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
+ // Node.js 20.16.0+ and 22.3.0+
12
+ if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
+ return __cjs_getProcess.getBuiltinModule(module);
14
+ }
15
+ }
16
+ // Fallback to createRequire
17
+ return __cjs_require(module);
18
+ };
19
+
20
+ const {
21
+ readFileSync
22
+ } = __cjs_getBuiltinModule("node:fs");
23
+ import { parse, stringify } from 'ini';
24
+ import { R_OK } from './F_OK-MldBaGxb.js';
25
+ import isAccessibleSync from './isAccessibleSync-DI8mM0fA.js';
26
+ import { d as detectIniStyle, m as mergeIniPreservingLines } from './ini-preserve-Dq_Q_Jgb.js';
27
+ import writeFileSync from './writeFileSync-DB8vv8xR.js';
28
+
29
+ const writeIniSync = (path, data, options = {}) => {
30
+ const { eol, preserveStyle = true, whitespace, ...rest } = options;
31
+ const { align, bracketedArray, newline, platform, section, sort, ...writeOptions } = rest;
32
+ let resolvedEol = eol;
33
+ let resolvedWhitespace = whitespace;
34
+ let existingText;
35
+ let oldData;
36
+ if (preserveStyle && isAccessibleSync(path, R_OK)) {
37
+ try {
38
+ existingText = readFileSync(path, "utf8");
39
+ oldData = parse(existingText, { bracketedArray: bracketedArray ?? true });
40
+ const detected = detectIniStyle(existingText);
41
+ resolvedEol ??= detected.eol;
42
+ resolvedWhitespace ??= detected.whitespace;
43
+ } catch (error) {
44
+ if (error.code !== "ENOENT") {
45
+ throw error;
46
+ }
47
+ }
48
+ }
49
+ const encodeOptions = { align, bracketedArray, newline, platform, section, sort, whitespace: resolvedWhitespace };
50
+ const freshStringify = (value, sectionName) => stringify(value, sectionName === void 0 ? encodeOptions : { ...encodeOptions, section: sectionName });
51
+ let output;
52
+ if (existingText !== void 0 && oldData) {
53
+ output = mergeIniPreservingLines(existingText, oldData, data, freshStringify, {
54
+ eol: resolvedEol ?? "\n"});
55
+ } else {
56
+ output = freshStringify(data, section);
57
+ if (resolvedEol === "\r\n") {
58
+ output = output.replaceAll(/\r?\n/g, "\r\n");
59
+ }
60
+ }
61
+ writeFileSync(path, output, writeOptions);
62
+ };
63
+
64
+ export { writeIniSync as default };
@@ -23,7 +23,7 @@ const {
23
23
  import { d as detectIndent } from './index-CHM-in-V.js';
24
24
  import { R_OK } from './F_OK-MldBaGxb.js';
25
25
  import isAccessible from './isAccessible-DuVrTNFV.js';
26
- import writeFile from './writeFile-DSHERs0Z.js';
26
+ import writeFile from './writeFile-B8HX0JIQ.js';
27
27
 
28
28
  const writeJson = async (path, data, options = {}) => {
29
29
  const { detectIndent: detectIndent$1, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: " ", ...options };
@@ -0,0 +1,53 @@
1
+ import { createRequire as __cjs_createRequire } from "node:module";
2
+
3
+ const __cjs_require = __cjs_createRequire(import.meta.url);
4
+
5
+ const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
+
7
+ const __cjs_getBuiltinModule = (module) => {
8
+ // Check if we're in Node.js and version supports getBuiltinModule
9
+ if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
+ const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
+ // Node.js 20.16.0+ and 22.3.0+
12
+ if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
+ return __cjs_getProcess.getBuiltinModule(module);
14
+ }
15
+ }
16
+ // Fallback to createRequire
17
+ return __cjs_require(module);
18
+ };
19
+
20
+ const {
21
+ readFile
22
+ } = __cjs_getBuiltinModule("node:fs/promises");
23
+ import { d as detectIndent } from './index-CHM-in-V.js';
24
+ import JSON5 from 'json5';
25
+ import { R_OK } from './F_OK-MldBaGxb.js';
26
+ import isAccessible from './isAccessible-DuVrTNFV.js';
27
+ import writeFile from './writeFile-B8HX0JIQ.js';
28
+
29
+ const writeJson5 = async (path, data, options = {}) => {
30
+ const { detectIndent: detectIndent$1, indent: indentOption, quote, replacer, ...writeOptions } = { indent: " ", ...options };
31
+ let indent = indentOption;
32
+ let trailingNewline = "\n";
33
+ if (await isAccessible(path, R_OK)) {
34
+ try {
35
+ const file = await readFile(path, "utf8");
36
+ if (detectIndent$1) {
37
+ const { indent: detectedIndent } = detectIndent(file);
38
+ if (detectedIndent) {
39
+ indent = detectedIndent;
40
+ }
41
+ }
42
+ trailingNewline = file.endsWith("\n") ? "\n" : "";
43
+ } catch (error) {
44
+ if (error.code !== "ENOENT") {
45
+ throw error;
46
+ }
47
+ }
48
+ }
49
+ const output = JSON5.stringify(data, { quote, replacer, space: indent });
50
+ await writeFile(path, `${output}${trailingNewline}`, writeOptions);
51
+ };
52
+
53
+ export { writeJson5 as default };
@@ -0,0 +1,53 @@
1
+ import { createRequire as __cjs_createRequire } from "node:module";
2
+
3
+ const __cjs_require = __cjs_createRequire(import.meta.url);
4
+
5
+ const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
+
7
+ const __cjs_getBuiltinModule = (module) => {
8
+ // Check if we're in Node.js and version supports getBuiltinModule
9
+ if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
+ const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
+ // Node.js 20.16.0+ and 22.3.0+
12
+ if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
+ return __cjs_getProcess.getBuiltinModule(module);
14
+ }
15
+ }
16
+ // Fallback to createRequire
17
+ return __cjs_require(module);
18
+ };
19
+
20
+ const {
21
+ readFileSync
22
+ } = __cjs_getBuiltinModule("node:fs");
23
+ import { d as detectIndent } from './index-CHM-in-V.js';
24
+ import JSON5 from 'json5';
25
+ import { R_OK } from './F_OK-MldBaGxb.js';
26
+ import isAccessibleSync from './isAccessibleSync-DI8mM0fA.js';
27
+ import writeFileSync from './writeFileSync-DB8vv8xR.js';
28
+
29
+ const writeJson5Sync = (path, data, options = {}) => {
30
+ const { detectIndent: detectIndent$1, indent: indentOption, quote, replacer, ...writeOptions } = { indent: " ", ...options };
31
+ let indent = indentOption;
32
+ let trailingNewline = "\n";
33
+ if (isAccessibleSync(path, R_OK)) {
34
+ try {
35
+ const file = readFileSync(path, "utf8");
36
+ if (detectIndent$1) {
37
+ const { indent: detectedIndent } = detectIndent(file);
38
+ if (detectedIndent) {
39
+ indent = detectedIndent;
40
+ }
41
+ }
42
+ trailingNewline = file.endsWith("\n") ? "\n" : "";
43
+ } catch (error) {
44
+ if (error.code !== "ENOENT") {
45
+ throw error;
46
+ }
47
+ }
48
+ }
49
+ const output = JSON5.stringify(data, { quote, replacer, space: indent });
50
+ writeFileSync(path, `${output}${trailingNewline}`, writeOptions);
51
+ };
52
+
53
+ export { writeJson5Sync as default };