@stryke/fs 0.33.69 → 0.33.71

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 (196) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
  3. package/dist/buffer.cjs +5 -4
  4. package/dist/buffer.d.cts.map +1 -1
  5. package/dist/buffer.d.mts.map +1 -1
  6. package/dist/buffer.mjs +1 -1
  7. package/dist/chmod-x.cjs +2 -1
  8. package/dist/chmod-x.d.cts.map +1 -1
  9. package/dist/chmod-x.d.mts.map +1 -1
  10. package/dist/chmod-x.mjs.map +1 -1
  11. package/dist/command-exists.cjs +3 -2
  12. package/dist/command-exists.d.cts.map +1 -1
  13. package/dist/command-exists.d.mts.map +1 -1
  14. package/dist/command-exists.mjs +1 -1
  15. package/dist/command-exists.mjs.map +1 -1
  16. package/dist/compress.cjs +7 -7
  17. package/dist/compress.d.cts.map +1 -1
  18. package/dist/compress.d.mts.map +1 -1
  19. package/dist/compress.mjs +5 -6
  20. package/dist/compress.mjs.map +1 -1
  21. package/dist/constants.d.cts.map +1 -1
  22. package/dist/constants.d.mts.map +1 -1
  23. package/dist/copy-file.cjs +16 -15
  24. package/dist/copy-file.d.cts +0 -1
  25. package/dist/copy-file.d.cts.map +1 -1
  26. package/dist/copy-file.d.mts +0 -1
  27. package/dist/copy-file.d.mts.map +1 -1
  28. package/dist/copy-file.mjs +6 -6
  29. package/dist/exists.cjs +2 -1
  30. package/dist/exists.d.cts.map +1 -1
  31. package/dist/exists.d.mts.map +1 -1
  32. package/dist/get-parent-path.cjs +14 -13
  33. package/dist/get-parent-path.d.cts.map +1 -1
  34. package/dist/get-parent-path.d.mts.map +1 -1
  35. package/dist/get-parent-path.mjs +6 -6
  36. package/dist/get-parent-path.mjs.map +1 -1
  37. package/dist/get-workspace-root.cjs +14 -13
  38. package/dist/get-workspace-root.d.cts.map +1 -1
  39. package/dist/get-workspace-root.d.mts.map +1 -1
  40. package/dist/get-workspace-root.mjs +3 -3
  41. package/dist/get-workspace-root.mjs.map +1 -1
  42. package/dist/helpers.cjs +2 -1
  43. package/dist/helpers.d.cts.map +1 -1
  44. package/dist/helpers.d.mts.map +1 -1
  45. package/dist/helpers.mjs.map +1 -1
  46. package/dist/index.cjs +1 -0
  47. package/dist/install.cjs +6 -5
  48. package/dist/install.d.cts +0 -2
  49. package/dist/install.d.cts.map +1 -1
  50. package/dist/install.d.mts +0 -3
  51. package/dist/install.d.mts.map +1 -1
  52. package/dist/install.mjs +1 -1
  53. package/dist/is-file.cjs +7 -6
  54. package/dist/is-file.d.cts.map +1 -1
  55. package/dist/is-file.d.mts.map +1 -1
  56. package/dist/is-file.mjs +1 -1
  57. package/dist/json/src/storm-json.cjs +3 -3
  58. package/dist/json/src/storm-json.mjs +1 -1
  59. package/dist/json/src/storm-json.mjs.map +1 -1
  60. package/dist/json/src/types.d.cts +0 -1
  61. package/dist/json/src/types.d.cts.map +1 -1
  62. package/dist/json/src/types.d.mts +0 -1
  63. package/dist/json/src/types.d.mts.map +1 -1
  64. package/dist/json/src/utils/code-frames.mjs.map +1 -1
  65. package/dist/json/src/utils/parse-error.cjs +1 -1
  66. package/dist/json/src/utils/stringify.mjs.map +1 -1
  67. package/dist/json/src/utils/strip-comments.cjs +4 -5
  68. package/dist/json/src/utils/strip-comments.mjs +4 -6
  69. package/dist/json/src/utils/strip-comments.mjs.map +1 -1
  70. package/dist/json.cjs +6 -4
  71. package/dist/json.d.cts +0 -1
  72. package/dist/json.d.cts.map +1 -1
  73. package/dist/json.d.mts +0 -1
  74. package/dist/json.d.mts.map +1 -1
  75. package/dist/json.mjs +2 -2
  76. package/dist/list-files.cjs +6 -5
  77. package/dist/list-files.d.cts.map +1 -1
  78. package/dist/list-files.d.mts.map +1 -1
  79. package/dist/list-files.mjs +1 -1
  80. package/dist/list-files.mjs.map +1 -1
  81. package/dist/package-fns.cjs +12 -11
  82. package/dist/package-fns.d.cts +0 -1
  83. package/dist/package-fns.d.cts.map +1 -1
  84. package/dist/package-fns.d.mts +0 -1
  85. package/dist/package-fns.d.mts.map +1 -1
  86. package/dist/package-fns.mjs +4 -4
  87. package/dist/read-file.cjs +2 -1
  88. package/dist/read-file.d.cts.map +1 -1
  89. package/dist/read-file.d.mts.map +1 -1
  90. package/dist/registry.cjs +4 -3
  91. package/dist/registry.d.cts.map +1 -1
  92. package/dist/registry.d.mts.map +1 -1
  93. package/dist/registry.mjs.map +1 -1
  94. package/dist/remove-file.cjs +2 -1
  95. package/dist/remove-file.d.cts.map +1 -1
  96. package/dist/remove-file.d.mts.map +1 -1
  97. package/dist/resolve.cjs +38 -37
  98. package/dist/resolve.d.cts.map +1 -1
  99. package/dist/resolve.d.mts.map +1 -1
  100. package/dist/resolve.mjs +18 -18
  101. package/dist/resolve.mjs.map +1 -1
  102. package/dist/semver-fns.cjs +5 -4
  103. package/dist/semver-fns.d.cts.map +1 -1
  104. package/dist/semver-fns.d.mts.map +1 -1
  105. package/dist/semver-fns.mjs +1 -1
  106. package/dist/semver-fns.mjs.map +1 -1
  107. package/dist/toml.cjs +3 -2
  108. package/dist/toml.d.cts +3 -4
  109. package/dist/toml.d.cts.map +1 -1
  110. package/dist/toml.d.mts +3 -4
  111. package/dist/toml.d.mts.map +1 -1
  112. package/dist/tsconfig.cjs +13 -12
  113. package/dist/tsconfig.d.cts +0 -1
  114. package/dist/tsconfig.d.cts.map +1 -1
  115. package/dist/tsconfig.d.mts +0 -1
  116. package/dist/tsconfig.d.mts.map +1 -1
  117. package/dist/tsconfig.mjs +5 -5
  118. package/dist/type-checks/src/index.cjs +3 -3
  119. package/dist/type-checks/src/index.mjs +3 -3
  120. package/dist/type-checks/src/is-buffer.cjs +2 -2
  121. package/dist/type-checks/src/is-buffer.mjs +1 -1
  122. package/dist/type-checks/src/is-buffer.mjs.map +1 -1
  123. package/dist/type-checks/src/is-set-string.cjs +1 -1
  124. package/dist/type-checks/src/is-set-string.mjs +1 -1
  125. package/dist/types/src/file.d.cts +0 -1
  126. package/dist/types/src/file.d.cts.map +1 -1
  127. package/dist/types/src/file.d.mts +0 -1
  128. package/dist/types/src/file.d.mts.map +1 -1
  129. package/dist/types/src/package-json.d.cts.map +1 -1
  130. package/dist/types/src/package-json.d.mts.map +1 -1
  131. package/dist/types/src/package-manager.d.cts.map +1 -1
  132. package/dist/types/src/package-manager.d.mts.map +1 -1
  133. package/dist/types/src/tsconfig.d.cts.map +1 -1
  134. package/dist/types/src/tsconfig.d.mts.map +1 -1
  135. package/dist/write-file.cjs +6 -5
  136. package/dist/write-file.d.cts.map +1 -1
  137. package/dist/write-file.d.mts.map +1 -1
  138. package/dist/write-file.mjs +2 -2
  139. package/dist/yaml.cjs +2 -1
  140. package/dist/yaml.d.cts.map +1 -1
  141. package/dist/yaml.d.mts.map +1 -1
  142. package/package.json +140 -59
  143. package/dist/convert/src/array-buffer-to-string.cjs +0 -19
  144. package/dist/convert/src/array-buffer-to-string.mjs +0 -19
  145. package/dist/convert/src/array-buffer-to-string.mjs.map +0 -1
  146. package/dist/convert/src/to-array.cjs +0 -15
  147. package/dist/convert/src/to-array.mjs +0 -15
  148. package/dist/convert/src/to-array.mjs.map +0 -1
  149. package/dist/convert/src/uint8-array-to-string.cjs +0 -15
  150. package/dist/convert/src/uint8-array-to-string.mjs +0 -16
  151. package/dist/convert/src/uint8-array-to-string.mjs.map +0 -1
  152. package/dist/helpers/src/get-unique.cjs +0 -14
  153. package/dist/helpers/src/get-unique.mjs +0 -14
  154. package/dist/helpers/src/get-unique.mjs.map +0 -1
  155. package/dist/path/src/append.cjs +0 -57
  156. package/dist/path/src/append.mjs +0 -57
  157. package/dist/path/src/append.mjs.map +0 -1
  158. package/dist/path/src/correct-path.cjs +0 -138
  159. package/dist/path/src/correct-path.mjs +0 -135
  160. package/dist/path/src/correct-path.mjs.map +0 -1
  161. package/dist/path/src/cwd.cjs +0 -17
  162. package/dist/path/src/cwd.mjs +0 -17
  163. package/dist/path/src/cwd.mjs.map +0 -1
  164. package/dist/path/src/file-path-fns.cjs +0 -178
  165. package/dist/path/src/file-path-fns.mjs +0 -171
  166. package/dist/path/src/file-path-fns.mjs.map +0 -1
  167. package/dist/path/src/is-parent-path.cjs +0 -32
  168. package/dist/path/src/is-parent-path.mjs +0 -33
  169. package/dist/path/src/is-parent-path.mjs.map +0 -1
  170. package/dist/path/src/is-root-dir.cjs +0 -14
  171. package/dist/path/src/is-root-dir.mjs +0 -14
  172. package/dist/path/src/is-root-dir.mjs.map +0 -1
  173. package/dist/path/src/is-type.cjs +0 -68
  174. package/dist/path/src/is-type.mjs +0 -67
  175. package/dist/path/src/is-type.mjs.map +0 -1
  176. package/dist/path/src/join-paths.cjs +0 -122
  177. package/dist/path/src/join-paths.mjs +0 -123
  178. package/dist/path/src/join-paths.mjs.map +0 -1
  179. package/dist/path/src/regex.cjs +0 -20
  180. package/dist/path/src/regex.mjs +0 -13
  181. package/dist/path/src/regex.mjs.map +0 -1
  182. package/dist/path/src/replace.cjs +0 -24
  183. package/dist/path/src/replace.mjs +0 -25
  184. package/dist/path/src/replace.mjs.map +0 -1
  185. package/dist/path/src/resolve-parent-path.cjs +0 -18
  186. package/dist/path/src/resolve-parent-path.mjs +0 -19
  187. package/dist/path/src/resolve-parent-path.mjs.map +0 -1
  188. package/dist/path/src/slash.cjs +0 -15
  189. package/dist/path/src/slash.mjs +0 -15
  190. package/dist/path/src/slash.mjs.map +0 -1
  191. package/dist/string-format/src/package.cjs +0 -92
  192. package/dist/string-format/src/package.mjs +0 -92
  193. package/dist/string-format/src/package.mjs.map +0 -1
  194. package/dist/types/src/base.cjs +0 -6
  195. package/dist/types/src/base.mjs +0 -6
  196. package/dist/types/src/base.mjs.map +0 -1
@@ -1,19 +0,0 @@
1
- //#region ../convert/src/array-buffer-to-string.ts
2
- /**
3
- * Convert an ArrayBuffer or Uint8Array to a string
4
- *
5
- * @param buffer - The ArrayBuffer or Uint8Array to convert
6
- * @returns The converted string
7
- */
8
- function arrayBufferToString(buffer) {
9
- const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
10
- const len = bytes.byteLength;
11
- if (len < 65535) return String.fromCharCode.apply(null, bytes);
12
- let binary = "";
13
- for (let i = 0; i < len; i++) binary += String.fromCharCode(bytes[i]);
14
- return binary;
15
- }
16
-
17
- //#endregion
18
- export { arrayBufferToString };
19
- //# sourceMappingURL=array-buffer-to-string.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"array-buffer-to-string.mjs","names":[],"sources":["../../../../convert/src/array-buffer-to-string.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Convert an ArrayBuffer or Uint8Array to a string\n *\n * @param buffer - The ArrayBuffer or Uint8Array to convert\n * @returns The converted string\n */\nexport function arrayBufferToString(\n buffer: ArrayBuffer | ArrayBufferLike | Uint8Array\n): string {\n const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);\n const len = bytes.byteLength;\n if (len < 65535) {\n return String.fromCharCode.apply(null, bytes as unknown as number[]);\n }\n let binary = \"\";\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]!);\n }\n return binary;\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,oBACd,QACQ;CACR,MAAM,QAAQ,kBAAkB,aAAa,SAAS,IAAI,WAAW,OAAO;CAC5E,MAAM,MAAM,MAAM;AAClB,KAAI,MAAM,MACR,QAAO,OAAO,aAAa,MAAM,MAAM,MAA6B;CAEtE,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,IACvB,WAAU,OAAO,aAAa,MAAM,GAAI;AAE1C,QAAO"}
@@ -1,15 +0,0 @@
1
-
2
- //#region ../convert/src/to-array.ts
3
- /**
4
- * Convert `Arrayable<T>` to `Array<T>`
5
- *
6
- * @param array - The `Arrayable<T>` to convert
7
- * @returns An `Array<T>` containing the elements of the input
8
- */
9
- function toArray(array) {
10
- array = array ?? [];
11
- return Array.isArray(array) ? array : [array];
12
- }
13
-
14
- //#endregion
15
- exports.toArray = toArray;
@@ -1,15 +0,0 @@
1
- //#region ../convert/src/to-array.ts
2
- /**
3
- * Convert `Arrayable<T>` to `Array<T>`
4
- *
5
- * @param array - The `Arrayable<T>` to convert
6
- * @returns An `Array<T>` containing the elements of the input
7
- */
8
- function toArray(array) {
9
- array = array ?? [];
10
- return Array.isArray(array) ? array : [array];
11
- }
12
-
13
- //#endregion
14
- export { toArray };
15
- //# sourceMappingURL=to-array.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"to-array.mjs","names":[],"sources":["../../../../convert/src/to-array.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Arrayable } from \"@stryke/types/array\";\nimport type { Nullable } from \"@stryke/types/utilities\";\n\n/**\n * Convert `Arrayable<T>` to `Array<T>`\n *\n * @param array - The `Arrayable<T>` to convert\n * @returns An `Array<T>` containing the elements of the input\n */\nexport function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T> {\n array = array ?? [];\n return Array.isArray(array) ? array : [array];\n}\n"],"mappings":";;;;;;;AA2BA,SAAgB,QAAW,OAA0C;AACnE,SAAQ,SAAS,EAAE;AACnB,QAAO,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM"}
@@ -1,15 +0,0 @@
1
- const require_array_buffer_to_string = require('./array-buffer-to-string.cjs');
2
-
3
- //#region ../convert/src/uint8-array-to-string.ts
4
- /**
5
- * Convert a Uint8Array to a base64 string
6
- *
7
- * @param buffer - The Uint8Array to convert
8
- * @returns The converted base64 string
9
- */
10
- function uint8ArrayToString(buffer) {
11
- return btoa(require_array_buffer_to_string.arrayBufferToString(buffer));
12
- }
13
-
14
- //#endregion
15
- exports.uint8ArrayToString = uint8ArrayToString;
@@ -1,16 +0,0 @@
1
- import { arrayBufferToString } from "./array-buffer-to-string.mjs";
2
-
3
- //#region ../convert/src/uint8-array-to-string.ts
4
- /**
5
- * Convert a Uint8Array to a base64 string
6
- *
7
- * @param buffer - The Uint8Array to convert
8
- * @returns The converted base64 string
9
- */
10
- function uint8ArrayToString(buffer) {
11
- return btoa(arrayBufferToString(buffer));
12
- }
13
-
14
- //#endregion
15
- export { uint8ArrayToString };
16
- //# sourceMappingURL=uint8-array-to-string.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uint8-array-to-string.mjs","names":[],"sources":["../../../../convert/src/uint8-array-to-string.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { arrayBufferToString } from \"./array-buffer-to-string\";\n\n/**\n * Convert a Uint8Array to a base64 string\n *\n * @param buffer - The Uint8Array to convert\n * @returns The converted base64 string\n */\nexport function uint8ArrayToString(buffer: Uint8Array): string {\n return btoa(arrayBufferToString(buffer));\n}\n"],"mappings":";;;;;;;;;AA0BA,SAAgB,mBAAmB,QAA4B;AAC7D,QAAO,KAAK,oBAAoB,OAAO,CAAC"}
@@ -1,14 +0,0 @@
1
-
2
- //#region ../helpers/src/get-unique.ts
3
- /**
4
- * Returns an array of unique values from the given array.
5
- *
6
- * @param arr - The array to get unique values from.
7
- * @returns An array of unique values.
8
- */
9
- const getUnique = (arr) => {
10
- return [...new Set(arr)];
11
- };
12
-
13
- //#endregion
14
- exports.getUnique = getUnique;
@@ -1,14 +0,0 @@
1
- //#region ../helpers/src/get-unique.ts
2
- /**
3
- * Returns an array of unique values from the given array.
4
- *
5
- * @param arr - The array to get unique values from.
6
- * @returns An array of unique values.
7
- */
8
- const getUnique = (arr) => {
9
- return [...new Set(arr)];
10
- };
11
-
12
- //#endregion
13
- export { getUnique };
14
- //# sourceMappingURL=get-unique.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-unique.mjs","names":[],"sources":["../../../../helpers/src/get-unique.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Returns an array of unique values from the given array.\n *\n * @param arr - The array to get unique values from.\n * @returns An array of unique values.\n */\nexport const getUnique = <T = any>(arr: T[]): T[] => {\n return [...new Set(arr)];\n};\n\n/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the mapper function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.2, 5.7, 7.19]\n * ```\n *\n * @param arr - The array to process.\n * @param mapper - The function used to convert the array elements.\n * @returns A new array containing only the unique elements from the original array, based on the values returned by the mapper function.\n */\nexport function getUniqueBy<T, U>(\n arr: readonly T[],\n mapper: (item: T) => U = item => item as unknown as U\n): T[] {\n const map = new Map<U, T>();\n\n for (const item of arr) {\n const key = mapper(item);\n\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":";;;;;;;AAwBA,MAAa,aAAsB,QAAkB;AACnD,QAAO,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC"}
@@ -1,57 +0,0 @@
1
- const require_cwd = require('./cwd.cjs');
2
- const require_slash = require('./slash.cjs');
3
- const require_is_parent_path = require('./is-parent-path.cjs');
4
- const require_join_paths = require('./join-paths.cjs');
5
-
6
- //#region ../path/src/append.ts
7
- /**
8
- * If not already a parent path, append the base path from the beginning of the given child path.
9
- *
10
- * @example
11
- * ```ts
12
- * appendPath("src/index.ts", "/home/user/project");
13
- * // returns "/home/user/project/src/index.ts"
14
- *
15
- * appendPath("/user/dev/app.ts", "/user/dev");
16
- * // returns "/user/dev/app.ts"
17
- *
18
- * appendPath("docs/readme.md");
19
- * // returns "<current_working_directory>/docs/readme.md"
20
- *
21
- * appendPath("src/index.ts", "/home/user/project", { skipIfAlreadyParent: false });
22
- * // returns "/home/user/project/src/index.ts"
23
- *
24
- * appendPath("/home/user/project/src/index.ts", "/home/user/project", { skipIfAlreadyParent: false });
25
- * // returns "/home/user/project/src/index.ts"
26
- * ```
27
- *
28
- * @param childPath - The child path to append to the {@link parentPath}
29
- * @param parentPath - The parent path to add the {@link childPath} to
30
- * @param options - Options for appending the path
31
- * @returns The {@link parentPath} with the {@link childPath} appended
32
- */
33
- function appendPath(childPath, parentPath = require_cwd.cwd(), options = {}) {
34
- return require_slash.slash(options.skipIfAlreadyParent !== false && require_is_parent_path.isParentPath(childPath, parentPath) ? childPath : require_join_paths.joinPaths(parentPath, childPath));
35
- }
36
- /**
37
- * Append the extension to the given path.
38
- *
39
- * @example
40
- * ```ts
41
- * appendExtension("/home/user/project/src/index", ".ts");
42
- * // returns "/home/user/project/src/index.ts"
43
- * appendExtension("/home/user/project/src/index.ts", ".js");
44
- * // returns "/home/user/project/src/index.ts.js"
45
- * ```
46
- *
47
- * @param path - The path to append the extension to.
48
- * @param extension - The extension to append.
49
- * @returns The path with the appended extension.
50
- */
51
- function appendExtension(path, extension) {
52
- return `${path}.${extension.replace(/^\./, "")}`;
53
- }
54
-
55
- //#endregion
56
- exports.appendExtension = appendExtension;
57
- exports.appendPath = appendPath;
@@ -1,57 +0,0 @@
1
- import { cwd } from "./cwd.mjs";
2
- import { slash } from "./slash.mjs";
3
- import { isParentPath } from "./is-parent-path.mjs";
4
- import { joinPaths } from "./join-paths.mjs";
5
-
6
- //#region ../path/src/append.ts
7
- /**
8
- * If not already a parent path, append the base path from the beginning of the given child path.
9
- *
10
- * @example
11
- * ```ts
12
- * appendPath("src/index.ts", "/home/user/project");
13
- * // returns "/home/user/project/src/index.ts"
14
- *
15
- * appendPath("/user/dev/app.ts", "/user/dev");
16
- * // returns "/user/dev/app.ts"
17
- *
18
- * appendPath("docs/readme.md");
19
- * // returns "<current_working_directory>/docs/readme.md"
20
- *
21
- * appendPath("src/index.ts", "/home/user/project", { skipIfAlreadyParent: false });
22
- * // returns "/home/user/project/src/index.ts"
23
- *
24
- * appendPath("/home/user/project/src/index.ts", "/home/user/project", { skipIfAlreadyParent: false });
25
- * // returns "/home/user/project/src/index.ts"
26
- * ```
27
- *
28
- * @param childPath - The child path to append to the {@link parentPath}
29
- * @param parentPath - The parent path to add the {@link childPath} to
30
- * @param options - Options for appending the path
31
- * @returns The {@link parentPath} with the {@link childPath} appended
32
- */
33
- function appendPath(childPath, parentPath = cwd(), options = {}) {
34
- return slash(options.skipIfAlreadyParent !== false && isParentPath(childPath, parentPath) ? childPath : joinPaths(parentPath, childPath));
35
- }
36
- /**
37
- * Append the extension to the given path.
38
- *
39
- * @example
40
- * ```ts
41
- * appendExtension("/home/user/project/src/index", ".ts");
42
- * // returns "/home/user/project/src/index.ts"
43
- * appendExtension("/home/user/project/src/index.ts", ".js");
44
- * // returns "/home/user/project/src/index.ts.js"
45
- * ```
46
- *
47
- * @param path - The path to append the extension to.
48
- * @param extension - The extension to append.
49
- * @returns The path with the appended extension.
50
- */
51
- function appendExtension(path, extension) {
52
- return `${path}.${extension.replace(/^\./, "")}`;
53
- }
54
-
55
- //#endregion
56
- export { appendExtension, appendPath };
57
- //# sourceMappingURL=append.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"append.mjs","names":[],"sources":["../../../../path/src/append.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { cwd } from \"./cwd\";\nimport { isParentPath } from \"./is-parent-path\";\nimport { joinPaths } from \"./join-paths\";\nimport { slash } from \"./slash\";\n\nexport interface AppendPathOptions {\n /**\n * If `true`, the function will skip appending if the `childPath` is already a child of the `parentPath`.\n *\n * @defaultValue true\n */\n skipIfAlreadyParent?: boolean;\n}\n\n/**\n * If not already a parent path, append the base path from the beginning of the given child path.\n *\n * @example\n * ```ts\n * appendPath(\"src/index.ts\", \"/home/user/project\");\n * // returns \"/home/user/project/src/index.ts\"\n *\n * appendPath(\"/user/dev/app.ts\", \"/user/dev\");\n * // returns \"/user/dev/app.ts\"\n *\n * appendPath(\"docs/readme.md\");\n * // returns \"<current_working_directory>/docs/readme.md\"\n *\n * appendPath(\"src/index.ts\", \"/home/user/project\", { skipIfAlreadyParent: false });\n * // returns \"/home/user/project/src/index.ts\"\n *\n * appendPath(\"/home/user/project/src/index.ts\", \"/home/user/project\", { skipIfAlreadyParent: false });\n * // returns \"/home/user/project/src/index.ts\"\n * ```\n *\n * @param childPath - The child path to append to the {@link parentPath}\n * @param parentPath - The parent path to add the {@link childPath} to\n * @param options - Options for appending the path\n * @returns The {@link parentPath} with the {@link childPath} appended\n */\nexport function appendPath(\n childPath: string,\n parentPath: string = cwd(),\n options: AppendPathOptions = {}\n): string {\n return slash(\n options.skipIfAlreadyParent !== false && isParentPath(childPath, parentPath)\n ? childPath\n : joinPaths(parentPath, childPath)\n );\n}\n\nexport const append = appendPath;\n\n/**\n * Append the extension to the given path.\n *\n * @example\n * ```ts\n * appendExtension(\"/home/user/project/src/index\", \".ts\");\n * // returns \"/home/user/project/src/index.ts\"\n * appendExtension(\"/home/user/project/src/index.ts\", \".js\");\n * // returns \"/home/user/project/src/index.ts.js\"\n * ```\n *\n * @param path - The path to append the extension to.\n * @param extension - The extension to append.\n * @returns The path with the appended extension.\n */\nexport function appendExtension(path: string, extension: string): string {\n return `${path}.${extension.replace(/^\\./, \"\")}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,WACd,WACA,aAAqB,KAAK,EAC1B,UAA6B,EAAE,EACvB;AACR,QAAO,MACL,QAAQ,wBAAwB,SAAS,aAAa,WAAW,WAAW,GACxE,YACA,UAAU,YAAY,UAAU,CACrC;;;;;;;;;;;;;;;;;AAoBH,SAAgB,gBAAgB,MAAc,WAA2B;AACvE,QAAO,GAAG,KAAK,GAAG,UAAU,QAAQ,OAAO,GAAG"}
@@ -1,138 +0,0 @@
1
- const require_cwd = require('./cwd.cjs');
2
- const require_regex = require('./regex.cjs');
3
- const require_is_type = require('./is-type.cjs');
4
- const require_slash = require('./slash.cjs');
5
- const require_append = require('./append.cjs');
6
-
7
- //#region ../path/src/correct-path.ts
8
- function normalizeWindowsPath(input = "") {
9
- if (!input) return input;
10
- return require_slash.slash(input).replace(require_regex.DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
11
- }
12
- /**
13
- * Corrects/normalized a file path.
14
- *
15
- * @param path - The path to correct.
16
- * @returns The corrected path.
17
- */
18
- function correctPath(path) {
19
- if (!path || path.length === 0) return ".";
20
- path = normalizeWindowsPath(path);
21
- const isUNCPath = path.match(require_regex.UNC_REGEX);
22
- const isPathAbsolute = require_is_type.isAbsolutePath(path);
23
- const trailingSeparator = path.endsWith("/");
24
- path = normalizeString(path, !isPathAbsolute);
25
- if (path.length === 0) {
26
- if (isPathAbsolute) return "/";
27
- return trailingSeparator ? "./" : ".";
28
- }
29
- if (trailingSeparator) path += "/";
30
- if (require_regex.DRIVE_LETTER_REGEX.test(path)) path += "/";
31
- if (isUNCPath) {
32
- if (!isPathAbsolute) return `//./${path}`;
33
- return `//${path}`;
34
- }
35
- return !path.startsWith("/") && isPathAbsolute && !require_regex.DRIVE_LETTER_REGEX.test(path) ? `/${path}` : path;
36
- }
37
- /**
38
- * Remove any star tokens (*) from the end of the file path
39
- *
40
- * @example
41
- * stripStars("src/**") // returns "src"
42
- * stripStars("src/*") // returns "src"
43
- * stripStars("src/**\/*") // returns "src"
44
- * stripStars("src/**\/*.txt") // returns "src"
45
- * stripStars("src/**\/file.txt") // returns "src"
46
- * stripStars("src/file.txt") // returns "src/file.txt"
47
- * stripStars("") // returns "."
48
- *
49
- * @param path - The path to correct.
50
- * @returns The corrected path.
51
- */
52
- function stripStars(path) {
53
- if (!path || path.length === 0) return ".";
54
- path = correctPath(path);
55
- let found = false;
56
- return `${path.startsWith("/") ? "/" : ""}${path.split("/").reduce((ret, segment) => {
57
- if (!segment?.trim()) return ret;
58
- if (found || segment.includes("*")) {
59
- found = true;
60
- return ret;
61
- }
62
- return ret + (ret ? `/${segment}` : segment);
63
- }, "")}`;
64
- }
65
- /**
66
- * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
67
- *
68
- * @param path - The path to normalize.
69
- * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
70
- * @returns the normalize path string.
71
- */
72
- function normalizeString(path, allowAboveRoot) {
73
- let res = "";
74
- let lastSegmentLength = 0;
75
- let lastSlash = -1;
76
- let dots = 0;
77
- let char = null;
78
- for (let index = 0; index <= path.length; ++index) {
79
- if (index < path.length) char = path[index];
80
- else if (char === "/") break;
81
- else char = "/";
82
- if (char === "/") {
83
- if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
84
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
85
- if (res.length > 2) {
86
- const lastSlashIndex = res.lastIndexOf("/");
87
- if (lastSlashIndex === -1) {
88
- res = "";
89
- lastSegmentLength = 0;
90
- } else {
91
- res = res.slice(0, lastSlashIndex);
92
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
93
- }
94
- lastSlash = index;
95
- dots = 0;
96
- continue;
97
- } else if (res.length > 0) {
98
- res = "";
99
- lastSegmentLength = 0;
100
- lastSlash = index;
101
- dots = 0;
102
- continue;
103
- }
104
- }
105
- if (allowAboveRoot) {
106
- res += res.length > 0 ? "/.." : "..";
107
- lastSegmentLength = 2;
108
- }
109
- } else {
110
- if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
111
- else res = path.slice(lastSlash + 1, index);
112
- lastSegmentLength = index - lastSlash - 1;
113
- }
114
- lastSlash = index;
115
- dots = 0;
116
- } else if (char === "." && dots !== -1) ++dots;
117
- else dots = -1;
118
- }
119
- return res;
120
- }
121
- /**
122
- * Converts a given path to an absolute path based on the current working directory.
123
- *
124
- * @param path - The path to convert to an absolute path.
125
- * @param cwd - The current working directory to use as the base path if the path is not absolute.
126
- * @returns The absolute path.
127
- */
128
- function toAbsolutePath(path, cwd$1 = require_cwd.cwd()) {
129
- if (require_is_type.isAbsolutePath(path)) return path;
130
- return require_slash.slash(normalizeString(require_append.appendPath(path, cwd$1), true));
131
- }
132
-
133
- //#endregion
134
- exports.correctPath = correctPath;
135
- exports.normalizeString = normalizeString;
136
- exports.normalizeWindowsPath = normalizeWindowsPath;
137
- exports.stripStars = stripStars;
138
- exports.toAbsolutePath = toAbsolutePath;
@@ -1,135 +0,0 @@
1
- import { cwd } from "./cwd.mjs";
2
- import { DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, UNC_REGEX } from "./regex.mjs";
3
- import { isAbsolutePath } from "./is-type.mjs";
4
- import { slash } from "./slash.mjs";
5
- import { appendPath } from "./append.mjs";
6
-
7
- //#region ../path/src/correct-path.ts
8
- function normalizeWindowsPath(input = "") {
9
- if (!input) return input;
10
- return slash(input).replace(DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
11
- }
12
- /**
13
- * Corrects/normalized a file path.
14
- *
15
- * @param path - The path to correct.
16
- * @returns The corrected path.
17
- */
18
- function correctPath(path) {
19
- if (!path || path.length === 0) return ".";
20
- path = normalizeWindowsPath(path);
21
- const isUNCPath = path.match(UNC_REGEX);
22
- const isPathAbsolute = isAbsolutePath(path);
23
- const trailingSeparator = path.endsWith("/");
24
- path = normalizeString(path, !isPathAbsolute);
25
- if (path.length === 0) {
26
- if (isPathAbsolute) return "/";
27
- return trailingSeparator ? "./" : ".";
28
- }
29
- if (trailingSeparator) path += "/";
30
- if (DRIVE_LETTER_REGEX.test(path)) path += "/";
31
- if (isUNCPath) {
32
- if (!isPathAbsolute) return `//./${path}`;
33
- return `//${path}`;
34
- }
35
- return !path.startsWith("/") && isPathAbsolute && !DRIVE_LETTER_REGEX.test(path) ? `/${path}` : path;
36
- }
37
- /**
38
- * Remove any star tokens (*) from the end of the file path
39
- *
40
- * @example
41
- * stripStars("src/**") // returns "src"
42
- * stripStars("src/*") // returns "src"
43
- * stripStars("src/**\/*") // returns "src"
44
- * stripStars("src/**\/*.txt") // returns "src"
45
- * stripStars("src/**\/file.txt") // returns "src"
46
- * stripStars("src/file.txt") // returns "src/file.txt"
47
- * stripStars("") // returns "."
48
- *
49
- * @param path - The path to correct.
50
- * @returns The corrected path.
51
- */
52
- function stripStars(path) {
53
- if (!path || path.length === 0) return ".";
54
- path = correctPath(path);
55
- let found = false;
56
- return `${path.startsWith("/") ? "/" : ""}${path.split("/").reduce((ret, segment) => {
57
- if (!segment?.trim()) return ret;
58
- if (found || segment.includes("*")) {
59
- found = true;
60
- return ret;
61
- }
62
- return ret + (ret ? `/${segment}` : segment);
63
- }, "")}`;
64
- }
65
- /**
66
- * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
67
- *
68
- * @param path - The path to normalize.
69
- * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
70
- * @returns the normalize path string.
71
- */
72
- function normalizeString(path, allowAboveRoot) {
73
- let res = "";
74
- let lastSegmentLength = 0;
75
- let lastSlash = -1;
76
- let dots = 0;
77
- let char = null;
78
- for (let index = 0; index <= path.length; ++index) {
79
- if (index < path.length) char = path[index];
80
- else if (char === "/") break;
81
- else char = "/";
82
- if (char === "/") {
83
- if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
84
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
85
- if (res.length > 2) {
86
- const lastSlashIndex = res.lastIndexOf("/");
87
- if (lastSlashIndex === -1) {
88
- res = "";
89
- lastSegmentLength = 0;
90
- } else {
91
- res = res.slice(0, lastSlashIndex);
92
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
93
- }
94
- lastSlash = index;
95
- dots = 0;
96
- continue;
97
- } else if (res.length > 0) {
98
- res = "";
99
- lastSegmentLength = 0;
100
- lastSlash = index;
101
- dots = 0;
102
- continue;
103
- }
104
- }
105
- if (allowAboveRoot) {
106
- res += res.length > 0 ? "/.." : "..";
107
- lastSegmentLength = 2;
108
- }
109
- } else {
110
- if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
111
- else res = path.slice(lastSlash + 1, index);
112
- lastSegmentLength = index - lastSlash - 1;
113
- }
114
- lastSlash = index;
115
- dots = 0;
116
- } else if (char === "." && dots !== -1) ++dots;
117
- else dots = -1;
118
- }
119
- return res;
120
- }
121
- /**
122
- * Converts a given path to an absolute path based on the current working directory.
123
- *
124
- * @param path - The path to convert to an absolute path.
125
- * @param cwd - The current working directory to use as the base path if the path is not absolute.
126
- * @returns The absolute path.
127
- */
128
- function toAbsolutePath(path, cwd$1 = cwd()) {
129
- if (isAbsolutePath(path)) return path;
130
- return slash(normalizeString(appendPath(path, cwd$1), true));
131
- }
132
-
133
- //#endregion
134
- export { correctPath, normalizeString, normalizeWindowsPath, stripStars, toAbsolutePath };
135
- //# sourceMappingURL=correct-path.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"correct-path.mjs","names":["char: string | null","currentDir","cwd"],"sources":["../../../../path/src/correct-path.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { appendPath } from \"./append\";\nimport { cwd as currentDir } from \"./cwd\";\nimport { isAbsolutePath } from \"./is-type\";\nimport { joinPaths } from \"./join-paths\";\nimport {\n DRIVE_LETTER_REGEX,\n DRIVE_LETTER_START_REGEX,\n UNC_REGEX\n} from \"./regex\";\nimport { slash } from \"./slash\";\n\n// Util to normalize windows paths to posix\nexport function normalizeWindowsPath(input = \"\") {\n if (!input) {\n return input;\n }\n\n return slash(input).replace(DRIVE_LETTER_START_REGEX, r => r.toUpperCase());\n}\n\n/**\n * Corrects/normalized a file path.\n *\n * @param path - The path to correct.\n * @returns The corrected path.\n */\nexport function correctPath(path?: string) {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n // Normalize windows argument\n path = normalizeWindowsPath(path);\n\n const isUNCPath = path.match(UNC_REGEX);\n const isPathAbsolute = isAbsolutePath(path);\n const trailingSeparator = path.endsWith(\"/\");\n\n // Normalize the path\n path = normalizeString(path, !isPathAbsolute);\n\n if (path.length === 0) {\n if (isPathAbsolute) {\n return \"/\";\n }\n return trailingSeparator ? \"./\" : \".\";\n }\n\n if (trailingSeparator) {\n path += \"/\";\n }\n if (DRIVE_LETTER_REGEX.test(path)) {\n path += \"/\";\n }\n\n if (isUNCPath) {\n if (!isPathAbsolute) {\n return `//./${path}`;\n }\n return `//${path}`;\n }\n\n return !path.startsWith(\"/\") &&\n isPathAbsolute &&\n !DRIVE_LETTER_REGEX.test(path)\n ? `/${path}`\n : path;\n}\n\n/**\n * Remove any star tokens (*) from the end of the file path\n *\n * @example\n * stripStars(\"src/**\") // returns \"src\"\n * stripStars(\"src/*\") // returns \"src\"\n * stripStars(\"src/**\\/*\") // returns \"src\"\n * stripStars(\"src/**\\/*.txt\") // returns \"src\"\n * stripStars(\"src/**\\/file.txt\") // returns \"src\"\n * stripStars(\"src/file.txt\") // returns \"src/file.txt\"\n * stripStars(\"\") // returns \".\"\n *\n * @param path - The path to correct.\n * @returns The corrected path.\n */\nexport function stripStars(path?: string) {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n path = correctPath(path);\n\n let found = false;\n\n return `${path.startsWith(\"/\") ? \"/\" : \"\"}${path\n .split(\"/\")\n .reduce((ret, segment) => {\n if (!segment?.trim()) {\n return ret;\n }\n\n if (found || segment.includes(\"*\")) {\n found = true;\n return ret;\n }\n\n return ret + (ret ? `/${segment}` : segment);\n }, \"\")}`;\n}\n\n/**\n * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.\n *\n * @param path - The path to normalize.\n * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.\n * @returns the normalize path string.\n */\nexport function normalizeString(path: string, allowAboveRoot: boolean) {\n let res = \"\";\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let char: string | null = null;\n for (let index = 0; index <= path.length; ++index) {\n if (index < path.length) {\n // casted because we know it exists thanks to the length check\n char = path[index] as string;\n } else if (char === \"/\") {\n break;\n } else {\n char = \"/\";\n }\n if (char === \"/\") {\n if (lastSlash === index - 1 || dots === 1) {\n // NOOP\n } else if (dots === 2) {\n if (\n res.length < 2 ||\n lastSegmentLength !== 2 ||\n res[res.length - 1] !== \".\" ||\n res[res.length - 2] !== \".\"\n ) {\n if (res.length > 2) {\n const lastSlashIndex = res.lastIndexOf(\"/\");\n if (lastSlashIndex === -1) {\n res = \"\";\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf(\"/\");\n }\n lastSlash = index;\n dots = 0;\n continue;\n } else if (res.length > 0) {\n res = \"\";\n lastSegmentLength = 0;\n lastSlash = index;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n res += res.length > 0 ? \"/..\" : \"..\";\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0) {\n res += `/${path.slice(lastSlash + 1, index)}`;\n } else {\n res = path.slice(lastSlash + 1, index);\n }\n lastSegmentLength = index - lastSlash - 1;\n }\n lastSlash = index;\n dots = 0;\n } else if (char === \".\" && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n\n/**\n * Converts a given path to an absolute path based on the current working directory.\n *\n * @param path - The path to convert to an absolute path.\n * @param cwd - The current working directory to use as the base path if the path is not absolute.\n * @returns The absolute path.\n */\nexport function toAbsolutePath(path: string, cwd = currentDir()): string {\n if (isAbsolutePath(path)) {\n return path;\n }\n\n return slash(normalizeString(appendPath(path, cwd), true));\n}\n\n/**\n * Converts a given path to a relative path based on the current working directory.\n *\n * @param path - The path to convert to a relative path.\n * @param cwd - The current working directory to use as the base path if the path is not absolute.\n * @returns The relative path.\n */\nexport function toRelativePath(path: string, cwd = currentDir()): string {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n if (isAbsolutePath(path)) {\n path = slash(normalizeString(path, true));\n } else {\n path = slash(normalizeString(joinPaths(cwd, path), true));\n }\n\n if (path.startsWith(\"./\")) {\n return path.slice(2);\n }\n\n return path;\n}\n\n/**\n * Adds a trailing slash to a path if it doesn't already have one.\n *\n * @param path - The path to modify.\n * @returns The modified path with a trailing slash.\n */\nexport function withTrailingSlash(path: string): string {\n const result = correctPath(path);\n\n return result.endsWith(\"/\") ? result : `${result}/`;\n}\n\n/**\n * Removes a trailing slash from a path if it has one.\n *\n * @param path - The path to modify.\n * @returns The modified path without a trailing slash.\n */\nexport function withoutTrailingSlash(path: string): string {\n const result = correctPath(path);\n\n return result.endsWith(\"/\") ? result.slice(0, -1) : result;\n}\n"],"mappings":"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"}
@@ -1,17 +0,0 @@
1
-
2
- //#region ../path/src/cwd.ts
3
- /**
4
- * Get the current working directory.
5
- *
6
- * @remarks
7
- * This function attempts to retrieve the current working directory using `process.cwd()`.
8
- *
9
- * @returns The current working directory or '/' if it cannot be determined
10
- */
11
- function cwd() {
12
- if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
13
- return "/";
14
- }
15
-
16
- //#endregion
17
- exports.cwd = cwd;
@@ -1,17 +0,0 @@
1
- //#region ../path/src/cwd.ts
2
- /**
3
- * Get the current working directory.
4
- *
5
- * @remarks
6
- * This function attempts to retrieve the current working directory using `process.cwd()`.
7
- *
8
- * @returns The current working directory or '/' if it cannot be determined
9
- */
10
- function cwd() {
11
- if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
12
- return "/";
13
- }
14
-
15
- //#endregion
16
- export { cwd };
17
- //# sourceMappingURL=cwd.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cwd.mjs","names":[],"sources":["../../../../path/src/cwd.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Get the current working directory.\n *\n * @remarks\n * This function attempts to retrieve the current working directory using `process.cwd()`.\n *\n * @returns The current working directory or '/' if it cannot be determined\n */\nexport function cwd() {\n if (typeof process !== \"undefined\" && typeof process.cwd === \"function\") {\n return process.cwd().replace(/\\\\/g, \"/\");\n }\n return \"/\";\n}\n"],"mappings":";;;;;;;;;AA0BA,SAAgB,MAAM;AACpB,KAAI,OAAO,YAAY,eAAe,OAAO,QAAQ,QAAQ,WAC3D,QAAO,QAAQ,KAAK,CAAC,QAAQ,OAAO,IAAI;AAE1C,QAAO"}