@stryke/fs 0.33.32 → 0.33.33

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 (191) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -1
  3. package/dist/buffer.cjs +60 -1
  4. package/dist/buffer.mjs +56 -1
  5. package/dist/buffer.mjs.map +1 -1
  6. package/dist/chmod-x.cjs +93 -1
  7. package/dist/chmod-x.d.cts.map +1 -1
  8. package/dist/chmod-x.mjs +87 -1
  9. package/dist/chmod-x.mjs.map +1 -1
  10. package/dist/command-exists.cjs +102 -1
  11. package/dist/command-exists.mjs +100 -1
  12. package/dist/command-exists.mjs.map +1 -1
  13. package/dist/compress.cjs +29 -1
  14. package/dist/compress.mjs +28 -1
  15. package/dist/compress.mjs.map +1 -1
  16. package/dist/constants.mjs +1 -1
  17. package/dist/convert/src/array-buffer-to-string.cjs +19 -1
  18. package/dist/convert/src/array-buffer-to-string.mjs +18 -1
  19. package/dist/convert/src/array-buffer-to-string.mjs.map +1 -1
  20. package/dist/convert/src/to-array.cjs +15 -1
  21. package/dist/convert/src/to-array.mjs +14 -1
  22. package/dist/convert/src/to-array.mjs.map +1 -1
  23. package/dist/convert/src/uint8-array-to-string.cjs +15 -1
  24. package/dist/convert/src/uint8-array-to-string.mjs +15 -1
  25. package/dist/convert/src/uint8-array-to-string.mjs.map +1 -1
  26. package/dist/copy-file.cjs +87 -1
  27. package/dist/copy-file.mjs +83 -1
  28. package/dist/copy-file.mjs.map +1 -1
  29. package/dist/exists.cjs +27 -1
  30. package/dist/exists.mjs +25 -1
  31. package/dist/exists.mjs.map +1 -1
  32. package/dist/get-parent-path.cjs +35 -1
  33. package/dist/get-parent-path.mjs +34 -1
  34. package/dist/get-parent-path.mjs.map +1 -1
  35. package/dist/get-workspace-root.cjs +158 -1
  36. package/dist/get-workspace-root.mjs +150 -1
  37. package/dist/get-workspace-root.mjs.map +1 -1
  38. package/dist/helpers/src/get-unique.cjs +14 -1
  39. package/dist/helpers/src/get-unique.mjs +13 -1
  40. package/dist/helpers/src/get-unique.mjs.map +1 -1
  41. package/dist/helpers.cjs +83 -1
  42. package/dist/helpers.mjs +77 -1
  43. package/dist/helpers.mjs.map +1 -1
  44. package/dist/index.cjs +122 -1
  45. package/dist/index.mjs +25 -1
  46. package/dist/install.cjs +35 -1
  47. package/dist/install.mjs +33 -1
  48. package/dist/install.mjs.map +1 -1
  49. package/dist/is-file.cjs +51 -1
  50. package/dist/is-file.mjs +47 -1
  51. package/dist/is-file.mjs.map +1 -1
  52. package/dist/json/src/storm-json.cjs +117 -1
  53. package/dist/json/src/storm-json.mjs +115 -1
  54. package/dist/json/src/storm-json.mjs.map +1 -1
  55. package/dist/json/src/utils/code-frames.cjs +77 -3
  56. package/dist/json/src/utils/code-frames.mjs +76 -3
  57. package/dist/json/src/utils/code-frames.mjs.map +1 -1
  58. package/dist/json/src/utils/parse-error.cjs +34 -1
  59. package/dist/json/src/utils/parse-error.mjs +33 -1
  60. package/dist/json/src/utils/parse-error.mjs.map +1 -1
  61. package/dist/json/src/utils/parse.cjs +45 -1
  62. package/dist/json/src/utils/parse.mjs +45 -1
  63. package/dist/json/src/utils/parse.mjs.map +1 -1
  64. package/dist/json/src/utils/stringify.cjs +67 -1
  65. package/dist/json/src/utils/stringify.mjs +67 -1
  66. package/dist/json/src/utils/stringify.mjs.map +1 -1
  67. package/dist/json/src/utils/strip-comments.cjs +86 -4
  68. package/dist/json/src/utils/strip-comments.mjs +86 -4
  69. package/dist/json/src/utils/strip-comments.mjs.map +1 -1
  70. package/dist/json.cjs +74 -1
  71. package/dist/json.mjs +71 -1
  72. package/dist/json.mjs.map +1 -1
  73. package/dist/list-files.cjs +86 -1
  74. package/dist/list-files.mjs +79 -1
  75. package/dist/list-files.mjs.map +1 -1
  76. package/dist/package-fns.cjs +148 -1
  77. package/dist/package-fns.mjs +141 -1
  78. package/dist/package-fns.mjs.map +1 -1
  79. package/dist/path/src/append.cjs +57 -1
  80. package/dist/path/src/append.mjs +56 -1
  81. package/dist/path/src/append.mjs.map +1 -1
  82. package/dist/path/src/correct-path.cjs +138 -1
  83. package/dist/path/src/correct-path.mjs +134 -1
  84. package/dist/path/src/correct-path.mjs.map +1 -1
  85. package/dist/path/src/cwd.cjs +17 -1
  86. package/dist/path/src/cwd.mjs +16 -1
  87. package/dist/path/src/cwd.mjs.map +1 -1
  88. package/dist/path/src/file-path-fns.cjs +169 -1
  89. package/dist/path/src/file-path-fns.mjs +164 -1
  90. package/dist/path/src/file-path-fns.mjs.map +1 -1
  91. package/dist/path/src/is-parent-path.cjs +32 -1
  92. package/dist/path/src/is-parent-path.mjs +32 -1
  93. package/dist/path/src/is-parent-path.mjs.map +1 -1
  94. package/dist/path/src/is-root-dir.cjs +14 -1
  95. package/dist/path/src/is-root-dir.mjs +13 -1
  96. package/dist/path/src/is-root-dir.mjs.map +1 -1
  97. package/dist/path/src/is-type.cjs +68 -1
  98. package/dist/path/src/is-type.mjs +66 -1
  99. package/dist/path/src/is-type.mjs.map +1 -1
  100. package/dist/path/src/join-paths.cjs +106 -1
  101. package/dist/path/src/join-paths.mjs +106 -1
  102. package/dist/path/src/join-paths.mjs.map +1 -1
  103. package/dist/path/src/regex.cjs +18 -1
  104. package/dist/path/src/regex.mjs +11 -1
  105. package/dist/path/src/regex.mjs.map +1 -1
  106. package/dist/path/src/replace.cjs +24 -1
  107. package/dist/path/src/replace.mjs +24 -1
  108. package/dist/path/src/replace.mjs.map +1 -1
  109. package/dist/path/src/resolve-parent-path.cjs +18 -1
  110. package/dist/path/src/resolve-parent-path.mjs +18 -1
  111. package/dist/path/src/resolve-parent-path.mjs.map +1 -1
  112. package/dist/path/src/slash.cjs +15 -1
  113. package/dist/path/src/slash.mjs +14 -1
  114. package/dist/path/src/slash.mjs.map +1 -1
  115. package/dist/read-file.cjs +47 -1
  116. package/dist/read-file.mjs +43 -1
  117. package/dist/read-file.mjs.map +1 -1
  118. package/dist/registry.cjs +142 -1
  119. package/dist/registry.mjs +137 -1
  120. package/dist/registry.mjs.map +1 -1
  121. package/dist/remove-file.cjs +27 -1
  122. package/dist/remove-file.mjs +25 -1
  123. package/dist/remove-file.mjs.map +1 -1
  124. package/dist/resolve.cjs +228 -3
  125. package/dist/resolve.mjs +217 -3
  126. package/dist/resolve.mjs.map +1 -1
  127. package/dist/semver-fns.cjs +129 -1
  128. package/dist/semver-fns.mjs +119 -1
  129. package/dist/semver-fns.mjs.map +1 -1
  130. package/dist/string-format/src/package.cjs +92 -1
  131. package/dist/string-format/src/package.mjs +91 -1
  132. package/dist/string-format/src/package.mjs.map +1 -1
  133. package/dist/toml.cjs +66 -3
  134. package/dist/toml.mjs +61 -3
  135. package/dist/toml.mjs.map +1 -1
  136. package/dist/tsconfig.cjs +37 -1
  137. package/dist/tsconfig.mjs +35 -1
  138. package/dist/tsconfig.mjs.map +1 -1
  139. package/dist/type-checks/src/get-object-tag.cjs +15 -1
  140. package/dist/type-checks/src/get-object-tag.mjs +14 -1
  141. package/dist/type-checks/src/get-object-tag.mjs.map +1 -1
  142. package/dist/type-checks/src/index.cjs +14 -1
  143. package/dist/type-checks/src/index.mjs +16 -1
  144. package/dist/type-checks/src/is-buffer.cjs +12 -1
  145. package/dist/type-checks/src/is-buffer.mjs +11 -1
  146. package/dist/type-checks/src/is-buffer.mjs.map +1 -1
  147. package/dist/type-checks/src/is-collection.cjs +1 -1
  148. package/dist/type-checks/src/is-collection.mjs +3 -1
  149. package/dist/type-checks/src/is-empty.cjs +20 -1
  150. package/dist/type-checks/src/is-empty.mjs +20 -1
  151. package/dist/type-checks/src/is-empty.mjs.map +1 -1
  152. package/dist/type-checks/src/is-error.cjs +29 -1
  153. package/dist/type-checks/src/is-error.mjs +29 -1
  154. package/dist/type-checks/src/is-error.mjs.map +1 -1
  155. package/dist/type-checks/src/is-null.cjs +12 -1
  156. package/dist/type-checks/src/is-null.mjs +11 -1
  157. package/dist/type-checks/src/is-null.mjs.map +1 -1
  158. package/dist/type-checks/src/is-number.cjs +18 -1
  159. package/dist/type-checks/src/is-number.mjs +17 -1
  160. package/dist/type-checks/src/is-number.mjs.map +1 -1
  161. package/dist/type-checks/src/is-object.cjs +19 -1
  162. package/dist/type-checks/src/is-object.mjs +19 -1
  163. package/dist/type-checks/src/is-object.mjs.map +1 -1
  164. package/dist/type-checks/src/is-plain-object.cjs +64 -1
  165. package/dist/type-checks/src/is-plain-object.mjs +63 -1
  166. package/dist/type-checks/src/is-plain-object.mjs.map +1 -1
  167. package/dist/type-checks/src/is-set-string.cjs +20 -1
  168. package/dist/type-checks/src/is-set-string.mjs +20 -1
  169. package/dist/type-checks/src/is-set-string.mjs.map +1 -1
  170. package/dist/type-checks/src/is-set.cjs +19 -1
  171. package/dist/type-checks/src/is-set.mjs +19 -1
  172. package/dist/type-checks/src/is-set.mjs.map +1 -1
  173. package/dist/type-checks/src/is-string.cjs +12 -1
  174. package/dist/type-checks/src/is-string.mjs +11 -1
  175. package/dist/type-checks/src/is-string.mjs.map +1 -1
  176. package/dist/type-checks/src/is-undefined.cjs +8 -1
  177. package/dist/type-checks/src/is-undefined.mjs +7 -1
  178. package/dist/type-checks/src/is-undefined.mjs.map +1 -1
  179. package/dist/type-checks/src/type-detect.cjs +15 -1
  180. package/dist/type-checks/src/type-detect.mjs +16 -1
  181. package/dist/type-checks/src/type-detect.mjs.map +1 -1
  182. package/dist/types/src/base.cjs +6 -1
  183. package/dist/types/src/base.mjs +5 -1
  184. package/dist/types/src/base.mjs.map +1 -1
  185. package/dist/write-file.cjs +40 -1
  186. package/dist/write-file.mjs +38 -1
  187. package/dist/write-file.mjs.map +1 -1
  188. package/dist/yaml.cjs +29 -1
  189. package/dist/yaml.mjs +27 -1
  190. package/dist/yaml.mjs.map +1 -1
  191. package/package.json +6 -6
@@ -1,2 +1,165 @@
1
- import{cwd as e}from"./cwd.mjs";import{FILE_EXTENSION_REGEX as t,ROOT_FOLDER_REGEX as n}from"./regex.mjs";import{isAbsolute as r}from"./is-type.mjs";import{normalizeString as i,normalizeWindowsPath as a}from"./correct-path.mjs";import{isSetString as o}from"../../type-checks/src/is-set-string.mjs";import{EMPTY_STRING as s}from"../../types/src/base.mjs";function c(e,t={}){let{requireExtension:n=!1,withExtension:r=!0}=t,i=a(e)?.split(e?.includes(`\\`)?`\\`:`/`)?.pop()??``;return n===!0&&!i.includes(`.`)?s:r===!1&&i.includes(`.`)?i.replace(`.${d(i)??``}`,``)||s:i}function l(e,t={}){let n=a(e),r=n.replace(c(n,{requireExtension:!1,...t}),``);return r===`/`?r:r.replace(/\/$/,``)}function u(e,t){let n=l(e,t).split(`/`),r=``;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){r=t;break}}return r??s}function d(e){if(e.endsWith(`.`)||e.endsWith(`/`))return;let n=t.exec(a(e));return n&&n.length>0&&o(n[0])?n[0].replace(`.`,``):void 0}function f(e){return!!d(e)}function p(...t){t=t.map(e=>a(e));let n=``,o=!1;for(let i=t.length-1;i>=-1&&!o;i--){let a=i>=0?t[i]:e();!a||a.length===0||(n=`${a}/${n}`,o=r(a))}return n=i(n,!o),o&&!r(n)?`/${n}`:n.length>0?n:`.`}function m(e,t){let r=p(e).replace(n,`$1`).split(`/`),i=p(t).replace(n,`$1`).split(`/`);if(i[0][1]===`:`&&r[0][1]===`:`&&r[0]!==i[0])return i.join(`/`);let a=[...r];for(let e of a){if(i[0]!==e)break;r.shift(),i.shift()}return[...r.map(()=>`..`),...i].join(`/`)}function h(e,t,n=!1){return m(n===!0?e:e.replace(/\/$/,``),n===!0?t:t.replace(/\/$/,``))}export{d as findFileExtension,c as findFileName,l as findFilePath,u as findFolderName,f as hasFileExtension,h as relativePath};
1
+ import { cwd } from "./cwd.mjs";
2
+ import { FILE_EXTENSION_REGEX, ROOT_FOLDER_REGEX } from "./regex.mjs";
3
+ import { isAbsolute } from "./is-type.mjs";
4
+ import { normalizeString, normalizeWindowsPath } from "./correct-path.mjs";
5
+ import { isSetString } from "../../type-checks/src/is-set-string.mjs";
6
+ import { EMPTY_STRING } from "../../types/src/base.mjs";
7
+
8
+ //#region ../path/src/file-path-fns.ts
9
+ /**
10
+ * Find the file name from a file path.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const fileName = findFileName("C:\\Users\\user\\Documents\\file.txt");
15
+ * // fileName = "file.txt"
16
+ * ```
17
+ *
18
+ * @param filePath - The file path to process
19
+ * @param options - Options to control the file name extraction
20
+ * @returns The file name
21
+ */
22
+ function findFileName(filePath, options = {}) {
23
+ const { requireExtension = false, withExtension = true } = options;
24
+ const result = normalizeWindowsPath(filePath)?.split(filePath?.includes("\\") ? "\\" : "/")?.pop() ?? "";
25
+ if (requireExtension === true && !result.includes(".")) return EMPTY_STRING;
26
+ if (withExtension === false && result.includes(".")) return result.replace(`.${findFileExtension(result) ?? ""}`, "") || EMPTY_STRING;
27
+ return result;
28
+ }
29
+ /**
30
+ * Find the full file path's directories from a file path.
31
+ *
32
+ * @remarks
33
+ * The functionality of this method is similar to the {@link path.dirname} function in Node's path module.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const folderPath = findFilePath("C:\\Users\\user\\Documents\\file.txt");
38
+ * // folderPath = "C:\\Users\\user\\Documents"
39
+ * ```
40
+ *
41
+ * @param filePath - The file path to process
42
+ * @param options - Options to control the file name extraction
43
+ * @returns The full file path's directories
44
+ */
45
+ function findFilePath(filePath, options = {}) {
46
+ const normalizedPath = normalizeWindowsPath(filePath);
47
+ const result = normalizedPath.replace(findFileName(normalizedPath, {
48
+ requireExtension: false,
49
+ ...options
50
+ }), "");
51
+ return result === "/" ? result : result.replace(/\/$/, "");
52
+ }
53
+ /**
54
+ * Find the top most folder containing the file from a file path.
55
+ *
56
+ * @remarks
57
+ * The functionality of this method is similar to the {@link path.basename} function in Node's path module.
58
+ * If you're looking for the full path of the folder (for example: `C:\\Users\\user\\Documents` instead of just `Documents`) containing the file, use {@link findFilePath} instead.
59
+ *
60
+ * @example
61
+ * const folderPath = findFolderName("C:\\Users\\user\\Documents\\file.txt");
62
+ * // folderPath = "Documents"
63
+ *
64
+ * @param filePath - The file path to process
65
+ * @param options - Options to control the file name extraction
66
+ * @returns The folder containing the file
67
+ */
68
+ function findFolderName(filePath, options) {
69
+ const segments = findFilePath(filePath, options).split("/");
70
+ let lastSegment = "";
71
+ for (let i = segments.length - 1; i >= 0; i--) {
72
+ const val = segments[i];
73
+ if (val) {
74
+ lastSegment = val;
75
+ break;
76
+ }
77
+ }
78
+ return lastSegment ?? EMPTY_STRING;
79
+ }
80
+ /**
81
+ * Find the file extension from a file path.
82
+ *
83
+ * @remarks
84
+ * The functionality of this method is similar to the {@link path.extname} function in Node's path module.
85
+ * The file extension is the part of the file name that comes after the last dot (`.`) in the file name. If the file name does not contain a dot, or if it ends with a dot, this function will return `undefined`.
86
+ *
87
+ * The returned extension **will not** include the dot, for example `txt` or `js` instead of `.txt` or `.js`.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * findFileExtension("C:\\Users\\user\\Documents\\file.config.ts");
92
+ * // Returns "ts"
93
+ * ```
94
+ *
95
+ * @param filePath - The file path to process
96
+ * @returns The file extension or undefined if no extension is found
97
+ */
98
+ function findFileExtension(filePath) {
99
+ if (filePath.endsWith(".") || filePath.endsWith("/")) return;
100
+ const match = FILE_EXTENSION_REGEX.exec(normalizeWindowsPath(filePath));
101
+ return match && match.length > 0 && isSetString(match[0]) ? match[0].replace(".", "") : void 0;
102
+ }
103
+ /**
104
+ * Check if a file path has a file extension.
105
+ *
106
+ * @param filePath - The file path to process
107
+ * @returns An indicator specifying if the file path has a file extension
108
+ */
109
+ function hasFileExtension(filePath) {
110
+ return Boolean(findFileExtension(filePath));
111
+ }
112
+ function resolve(...paths) {
113
+ paths = paths.map((argument) => normalizeWindowsPath(argument));
114
+ let resolvedPath = "";
115
+ let resolvedAbsolute = false;
116
+ for (let index = paths.length - 1; index >= -1 && !resolvedAbsolute; index--) {
117
+ const path = index >= 0 ? paths[index] : cwd();
118
+ if (!path || path.length === 0) continue;
119
+ resolvedPath = `${path}/${resolvedPath}`;
120
+ resolvedAbsolute = isAbsolute(path);
121
+ }
122
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
123
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
124
+ return resolvedPath.length > 0 ? resolvedPath : ".";
125
+ }
126
+ /**
127
+ * Get the relative path from one file to another.
128
+ *
129
+ * @remarks
130
+ * This function is similar to the `path.relative` function in Node's path module.
131
+ *
132
+ * @param from - The base path to start from
133
+ * @param to - The target path to resolve relative to the base path
134
+ * @returns The relative path from the base path to the target path
135
+ */
136
+ function relative(from, to) {
137
+ const _from = resolve(from).replace(ROOT_FOLDER_REGEX, "$1").split("/");
138
+ const _to = resolve(to).replace(ROOT_FOLDER_REGEX, "$1").split("/");
139
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) return _to.join("/");
140
+ const _fromCopy = [..._from];
141
+ for (const segment of _fromCopy) {
142
+ if (_to[0] !== segment) break;
143
+ _from.shift();
144
+ _to.shift();
145
+ }
146
+ return [..._from.map(() => ".."), ..._to].join("/");
147
+ }
148
+ /**
149
+ * Get the relative path from one file to another.
150
+ *
151
+ * @remarks
152
+ * This function wraps the `path.relative` function in Node's path module.
153
+ *
154
+ * @param from - The base path to start from
155
+ * @param to - The target path to resolve relative to the base path
156
+ * @param withEndSlash - Whether to include a trailing slash at the end of the path
157
+ * @returns The relative path from the base path to the target path
158
+ */
159
+ function relativePath(from, to, withEndSlash = false) {
160
+ return relative(withEndSlash !== true ? from.replace(/\/$/, "") : from, withEndSlash !== true ? to.replace(/\/$/, "") : to);
161
+ }
162
+
163
+ //#endregion
164
+ export { findFileExtension, findFileName, findFilePath, findFolderName, hasFileExtension, relativePath };
2
165
  //# sourceMappingURL=file-path-fns.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-path-fns.mjs","names":["currentDir"],"sources":["../../../../path/src/file-path-fns.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 { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { EMPTY_STRING } from \"@stryke/types/base\";\nimport { normalizeString, normalizeWindowsPath } from \"./correct-path\";\nimport { cwd as currentDir } from \"./cwd\";\nimport { isAbsolute, isAbsolutePath } from \"./is-type\";\nimport { joinPaths } from \"./join-paths\";\nimport { FILE_EXTENSION_REGEX, ROOT_FOLDER_REGEX } from \"./regex\";\n\nexport interface FindFileNameOptions {\n /**\n * Require the file extension to be present in the file name.\n *\n * @defaultValue false\n */\n requireExtension?: boolean;\n\n /**\n * Return the file extension as part of the full file name result.\n *\n * @defaultValue true\n */\n withExtension?: boolean;\n}\n\n/**\n * Find the file name from a file path.\n *\n * @example\n * ```ts\n * const fileName = findFileName(\"C:\\\\Users\\\\user\\\\Documents\\\\file.txt\");\n * // fileName = \"file.txt\"\n * ```\n *\n * @param filePath - The file path to process\n * @param options - Options to control the file name extraction\n * @returns The file name\n */\nexport function findFileName(\n filePath: string,\n options: FindFileNameOptions = {}\n): string {\n const { requireExtension = false, withExtension = true } = options;\n const result =\n normalizeWindowsPath(filePath)\n ?.split(filePath?.includes(\"\\\\\") ? \"\\\\\" : \"/\")\n ?.pop() ?? \"\";\n\n if (requireExtension === true && !result.includes(\".\")) {\n return EMPTY_STRING;\n }\n\n if (withExtension === false && result.includes(\".\")) {\n return (\n result.replace(`.${findFileExtension(result) ?? \"\"}`, \"\") || EMPTY_STRING\n );\n }\n\n return result;\n}\n\n/**\n * Find the full file path's directories from a file path.\n *\n * @remarks\n * The functionality of this method is similar to the {@link path.dirname} function in Node's path module.\n *\n * @example\n * ```ts\n * const folderPath = findFilePath(\"C:\\\\Users\\\\user\\\\Documents\\\\file.txt\");\n * // folderPath = \"C:\\\\Users\\\\user\\\\Documents\"\n * ```\n *\n * @param filePath - The file path to process\n * @param options - Options to control the file name extraction\n * @returns The full file path's directories\n */\nexport function findFilePath(\n filePath: string,\n options: FindFileNameOptions = {}\n): string {\n const normalizedPath = normalizeWindowsPath(filePath);\n\n const result = normalizedPath.replace(\n findFileName(normalizedPath, { requireExtension: false, ...options }),\n \"\"\n );\n\n return result === \"/\" ? result : result.replace(/\\/$/, \"\");\n}\n\nexport const dirname = findFilePath;\n\n/**\n * Find the top most folder containing the file from a file path.\n *\n * @remarks\n * The functionality of this method is similar to the {@link path.basename} function in Node's path module.\n * If you're looking for the full path of the folder (for example: `C:\\\\Users\\\\user\\\\Documents` instead of just `Documents`) containing the file, use {@link findFilePath} instead.\n *\n * @example\n * const folderPath = findFolderName(\"C:\\\\Users\\\\user\\\\Documents\\\\file.txt\");\n * // folderPath = \"Documents\"\n *\n * @param filePath - The file path to process\n * @param options - Options to control the file name extraction\n * @returns The folder containing the file\n */\nexport function findFolderName(\n filePath: string,\n options?: FindFileNameOptions\n): string {\n const segments = findFilePath(filePath, options).split(\"/\");\n\n let lastSegment = \"\";\n for (let i = segments.length - 1; i >= 0; i--) {\n const val = segments[i];\n if (val) {\n lastSegment = val;\n break;\n }\n }\n\n // if (\n // folderPath.lastIndexOf(\"\\\\\") === folderPath.length - 1 ||\n // folderPath.lastIndexOf(\"/\") === folderPath.length - 1\n // ) {\n // folderPath = folderPath.slice(0, Math.max(0, folderPath.length - 1));\n // }\n\n return lastSegment ?? EMPTY_STRING;\n}\n\nexport const basename = findFolderName;\n\n/**\n * Find the file extension from a file path.\n *\n * @remarks\n * The functionality of this method is similar to the {@link path.extname} function in Node's path module.\n * The file extension is the part of the file name that comes after the last dot (`.`) in the file name. If the file name does not contain a dot, or if it ends with a dot, this function will return `undefined`.\n *\n * The returned extension **will not** include the dot, for example `txt` or `js` instead of `.txt` or `.js`.\n *\n * @example\n * ```ts\n * findFileExtension(\"C:\\\\Users\\\\user\\\\Documents\\\\file.config.ts\");\n * // Returns \"ts\"\n * ```\n *\n * @param filePath - The file path to process\n * @returns The file extension or undefined if no extension is found\n */\nexport function findFileExtension(filePath: string): string | undefined {\n if (filePath.endsWith(\".\") || filePath.endsWith(\"/\")) {\n return undefined;\n }\n\n const match = FILE_EXTENSION_REGEX.exec(normalizeWindowsPath(filePath));\n\n return match && match.length > 0 && isSetString(match[0])\n ? match[0].replace(\".\", \"\")\n : undefined;\n}\n\nexport const extname = findFileExtension;\n\n/**\n * Find the file extension including the `\".\"` character prefix from a file path.\n *\n * @remarks\n * The file extension is the part of the file name that comes after (and including) the last dot (`.`) in the file name. If the file name does not contain a dot, or if it ends with a dot, this function will return `undefined`.\n *\n * The returned extension **will** include the dot, for example `.txt` or `.js` instead of `txt` or `js`.\n *\n * @param filePath - The file path to process\n * @returns The file extension (including the `\".\"` prefix) or undefined if no extension is found\n */\nexport function findFileDotExtension(filePath: string): string | undefined {\n const ext = findFileExtension(filePath);\n\n return ext ? `.${ext}` : undefined;\n}\n\n/**\n * Find the file extension from a file path or an empty string.\n *\n * @remarks\n * The file extension is the part of the file name that comes after the last dot (`.`) in the file name. If the file name does not contain a dot, or if it ends with a dot, this function will return `undefined`.\n *\n * The returned extension **will not** include the dot, for example `txt` or `js` instead of `.txt` or `.js`.\n *\n * @param filePath - The file path to process\n * @returns The file extension or an empty string if no extension is found\n */\nexport function findFileExtensionSafe(filePath: string): string {\n return findFileExtension(filePath) ?? EMPTY_STRING;\n}\n\n/**\n * Find the file extension including the `\".\"` character prefix from a file path or an empty string.\n *\n * @remarks\n * The file extension is the part of the file name that comes after (and including) the last dot (`.`) in the file name. If the file name does not contain a dot, or if it ends with a dot, this function will return `undefined`.\n *\n * The returned extension **will** include the dot, for example `.txt` or `.js` instead of `txt` or `js`.\n *\n * @param filePath - The file path to process\n * @returns The file extension (including the `\".\"` prefix) or an empty string if no extension is found\n */\nexport function findFileDotExtensionSafe(filePath: string): string {\n const ext = findFileExtension(filePath);\n\n return ext ? `.${ext}` : \"\";\n}\n\n/**\n * Check if a file path has a file name.\n *\n * @param filePath - The file path to process\n * @returns An indicator specifying if the file path has a file name\n */\nexport function hasFileName(filePath: string): boolean {\n return Boolean(findFileName(filePath));\n}\n\n/**\n * Check if a file path has a file path.\n *\n * @param filePath - The file path to process\n * @returns An indicator specifying if the file path has a file path\n */\nexport function hasFilePath(filePath: string): boolean {\n return Boolean(findFilePath(filePath));\n}\n\n/**\n * Check if a file path has a folder name.\n *\n * @param filePath - The file path to process\n * @returns An indicator specifying if the file path has a folder name\n */\nexport function hasFolderName(filePath: string): boolean {\n return Boolean(findFolderName(filePath));\n}\n\n/**\n * Check if a file path has a file extension.\n *\n * @param filePath - The file path to process\n * @returns An indicator specifying if the file path has a file extension\n */\nexport function hasFileExtension(filePath: string): boolean {\n return Boolean(findFileExtension(filePath));\n}\n\n/**\n * Resolve the file path to an absolute path.\n *\n * @param path - The path to resolve\n * @param cwd - The current working directory\n * @returns The resolved path\n */\nexport function resolvePath(path: string, cwd = currentDir()) {\n // Normalize windows arguments\n const paths = normalizeWindowsPath(path).split(\"/\");\n\n let resolvedPath = \"\";\n let resolvedAbsolute = false;\n\n for (\n let index = paths.length - 1;\n index >= -1 && !resolvedAbsolute;\n index--\n ) {\n const path = index >= 0 ? paths[index] : cwd;\n\n // Skip empty entries\n if (!path || path.length === 0) {\n continue;\n }\n\n resolvedPath = joinPaths(path, resolvedPath);\n resolvedAbsolute = isAbsolutePath(path);\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);\n\n if (resolvedAbsolute && !isAbsolutePath(resolvedPath)) {\n return `/${resolvedPath}`;\n }\n\n return resolvedPath.length > 0 ? resolvedPath : \".\";\n}\n\nexport function resolve(...paths: string[]) {\n // Normalize windows arguments\n paths = paths.map(argument => normalizeWindowsPath(argument));\n\n let resolvedPath = \"\";\n let resolvedAbsolute = false;\n\n for (\n let index = paths.length - 1;\n index >= -1 && !resolvedAbsolute;\n index--\n ) {\n const path = index >= 0 ? paths[index] : currentDir();\n\n // Skip empty entries\n if (!path || path.length === 0) {\n continue;\n }\n\n resolvedPath = `${path}/${resolvedPath}`;\n resolvedAbsolute = isAbsolute(path);\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);\n\n if (resolvedAbsolute && !isAbsolute(resolvedPath)) {\n return `/${resolvedPath}`;\n }\n\n return resolvedPath.length > 0 ? resolvedPath : \".\";\n}\n\n/**\n * Resolve the file path to an absolute path.\n *\n * @param paths - The paths to resolve\n * @returns The resolved path\n */\nexport function resolvePaths(...paths: string[]) {\n return resolvePath(\n joinPaths(...paths.map(path => normalizeWindowsPath(path)))\n );\n}\n\n/**\n * Get the relative path from one file to another.\n *\n * @remarks\n * This function is similar to the `path.relative` function in Node's path module.\n *\n * @param from - The base path to start from\n * @param to - The target path to resolve relative to the base path\n * @returns The relative path from the base path to the target path\n */\nexport function relative(from: string, to: string) {\n // we cast these because `split` will always be at least one string\n const _from = resolve(from).replace(ROOT_FOLDER_REGEX, \"$1\").split(\"/\") as [\n string,\n ...string[]\n ];\n const _to = resolve(to).replace(ROOT_FOLDER_REGEX, \"$1\").split(\"/\") as [\n string,\n ...string[]\n ];\n\n // Different windows drive letters\n if (_to[0][1] === \":\" && _from[0][1] === \":\" && _from[0] !== _to[0]) {\n return _to.join(\"/\");\n }\n\n const _fromCopy = [..._from];\n for (const segment of _fromCopy) {\n if (_to[0] !== segment) {\n break;\n }\n _from.shift();\n _to.shift();\n }\n return [..._from.map(() => \"..\"), ..._to].join(\"/\");\n}\n\n/**\n * Get the relative path from one file to another.\n *\n * @remarks\n * This function wraps the `path.relative` function in Node's path module.\n *\n * @param from - The base path to start from\n * @param to - The target path to resolve relative to the base path\n * @param withEndSlash - Whether to include a trailing slash at the end of the path\n * @returns The relative path from the base path to the target path\n */\nexport function relativePath(from: string, to: string, withEndSlash = false) {\n return relative(\n withEndSlash !== true ? from.replace(/\\/$/, \"\") : from,\n withEndSlash !== true ? to.replace(/\\/$/, \"\") : to\n );\n}\n\n/**\n * Find the file path relative to the workspace root path.\n *\n * @param filePath - The file path to process\n * @returns The resolved file path\n */\nexport function relativeToCurrentDir(filePath: string) {\n return relativePath(filePath, currentDir());\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function parsePath(path: string) {\n // The root of the path such as '/' or 'c:\\'\n const root =\n /^[/\\\\]|^[a-z]:[/\\\\]/i.exec(path)?.[0]?.replace(/\\\\/g, \"/\") || \"\";\n\n const normalizedPath = normalizeWindowsPath(path);\n\n const segments = normalizedPath.replace(/\\/$/, \"\").split(\"/\").slice(0, -1);\n if (segments.length === 1 && /^[A-Z]:$/i.test(segments[0] as string)) {\n segments[0] += \"/\";\n }\n\n const base = findFolderName(normalizedPath);\n const dir = segments.join(\"/\") || (isAbsolutePath(path) ? \"/\" : \".\");\n const ext = findFileExtensionSafe(path);\n\n return {\n root,\n dir,\n base,\n ext,\n name: base.slice(0, base.length - ext.length)\n };\n}\n\n/**\n * Rename the file name with a new name.\n *\n * @param filePath - The current file path being processed\n * @param newFileName - The updated file name being processed\n * @returns The modified or unmodified file path.\n */\nexport function renameFile(filePath: string, newFileName: string): string {\n const file = parsePath(filePath);\n\n return joinPaths(\n file.dir,\n newFileName.includes(\".\") ? newFileName : newFileName + file.ext\n );\n}\n"],"mappings":"kWAuDA,SAAgB,EACd,EACA,EAA+B,EAAE,CACzB,CACR,GAAM,CAAE,mBAAmB,GAAO,gBAAgB,IAAS,EACrD,EACJ,EAAqB,EAAS,EAC1B,MAAM,GAAU,SAAS,KAAK,CAAG,KAAO,IAAI,EAC5C,KAAK,EAAI,GAYf,OAVI,IAAqB,IAAQ,CAAC,EAAO,SAAS,IAAI,CAC7C,EAGL,IAAkB,IAAS,EAAO,SAAS,IAAI,CAE/C,EAAO,QAAQ,IAAI,EAAkB,EAAO,EAAI,KAAM,GAAG,EAAI,EAI1D,EAmBT,SAAgB,EACd,EACA,EAA+B,EAAE,CACzB,CACR,IAAM,EAAiB,EAAqB,EAAS,CAE/C,EAAS,EAAe,QAC5B,EAAa,EAAgB,CAAE,iBAAkB,GAAO,GAAG,EAAS,CAAC,CACrE,GACD,CAED,OAAO,IAAW,IAAM,EAAS,EAAO,QAAQ,MAAO,GAAG,CAoB5D,SAAgB,EACd,EACA,EACQ,CACR,IAAM,EAAW,EAAa,EAAU,EAAQ,CAAC,MAAM,IAAI,CAEvD,EAAc,GAClB,IAAK,IAAI,EAAI,EAAS,OAAS,EAAG,GAAK,EAAG,IAAK,CAC7C,IAAM,EAAM,EAAS,GACrB,GAAI,EAAK,CACP,EAAc,EACd,OAWJ,OAAO,GAAe,EAuBxB,SAAgB,EAAkB,EAAsC,CACtE,GAAI,EAAS,SAAS,IAAI,EAAI,EAAS,SAAS,IAAI,CAClD,OAGF,IAAM,EAAQ,EAAqB,KAAK,EAAqB,EAAS,CAAC,CAEvE,OAAO,GAAS,EAAM,OAAS,GAAK,EAAY,EAAM,GAAG,CACrD,EAAM,GAAG,QAAQ,IAAK,GAAG,CACzB,IAAA,GA0FN,SAAgB,EAAiB,EAA2B,CAC1D,MAAO,EAAQ,EAAkB,EAAS,CA8C5C,SAAgB,EAAQ,GAAG,EAAiB,CAE1C,EAAQ,EAAM,IAAI,GAAY,EAAqB,EAAS,CAAC,CAE7D,IAAI,EAAe,GACf,EAAmB,GAEvB,IACE,IAAI,EAAQ,EAAM,OAAS,EAC3B,GAAS,IAAM,CAAC,EAChB,IACA,CACA,IAAM,EAAO,GAAS,EAAI,EAAM,GAASA,GAAY,CAGjD,CAAC,GAAQ,EAAK,SAAW,IAI7B,EAAe,GAAG,EAAK,GAAG,IAC1B,EAAmB,EAAW,EAAK,EAarC,MANA,GAAe,EAAgB,EAAc,CAAC,EAAiB,CAE3D,GAAoB,CAAC,EAAW,EAAa,CACxC,IAAI,IAGN,EAAa,OAAS,EAAI,EAAe,IAyBlD,SAAgB,EAAS,EAAc,EAAY,CAEjD,IAAM,EAAQ,EAAQ,EAAK,CAAC,QAAQ,EAAmB,KAAK,CAAC,MAAM,IAAI,CAIjE,EAAM,EAAQ,EAAG,CAAC,QAAQ,EAAmB,KAAK,CAAC,MAAM,IAAI,CAMnE,GAAI,EAAI,GAAG,KAAO,KAAO,EAAM,GAAG,KAAO,KAAO,EAAM,KAAO,EAAI,GAC/D,OAAO,EAAI,KAAK,IAAI,CAGtB,IAAM,EAAY,CAAC,GAAG,EAAM,CAC5B,IAAK,IAAM,KAAW,EAAW,CAC/B,GAAI,EAAI,KAAO,EACb,MAEF,EAAM,OAAO,CACb,EAAI,OAAO,CAEb,MAAO,CAAC,GAAG,EAAM,QAAU,KAAK,CAAE,GAAG,EAAI,CAAC,KAAK,IAAI,CAcrD,SAAgB,EAAa,EAAc,EAAY,EAAe,GAAO,CAC3E,OAAO,EACL,IAAiB,GAAiC,EAA1B,EAAK,QAAQ,MAAO,GAAG,CAC/C,IAAiB,GAA+B,EAAxB,EAAG,QAAQ,MAAO,GAAG,CAC9C"}
1
+ {"version":3,"file":"file-path-fns.mjs","names":["currentDir"],"sources":["../../../../path/src/file-path-fns.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 { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { EMPTY_STRING } from \"@stryke/types/base\";\nimport { normalizeString, normalizeWindowsPath } from \"./correct-path\";\nimport { cwd as currentDir } from \"./cwd\";\nimport { isAbsolute, isAbsolutePath } from \"./is-type\";\nimport { joinPaths } from \"./join-paths\";\nimport { FILE_EXTENSION_REGEX, ROOT_FOLDER_REGEX } from \"./regex\";\n\nexport interface FindFileNameOptions {\n /**\n * Require the file extension to be present in the file name.\n *\n * @defaultValue false\n */\n requireExtension?: boolean;\n\n /**\n * Return the file extension as part of the full file name result.\n *\n * @defaultValue true\n */\n withExtension?: boolean;\n}\n\n/**\n * Find the file name from a file path.\n *\n * @example\n * ```ts\n * const fileName = findFileName(\"C:\\\\Users\\\\user\\\\Documents\\\\file.txt\");\n * // fileName = \"file.txt\"\n * ```\n *\n * @param filePath - The file path to process\n * @param options - Options to control the file name extraction\n * @returns The file name\n */\nexport function findFileName(\n filePath: string,\n options: FindFileNameOptions = {}\n): string {\n const { requireExtension = false, withExtension = true } = options;\n const result =\n normalizeWindowsPath(filePath)\n ?.split(filePath?.includes(\"\\\\\") ? \"\\\\\" : \"/\")\n ?.pop() ?? \"\";\n\n if (requireExtension === true && !result.includes(\".\")) {\n return EMPTY_STRING;\n }\n\n if (withExtension === false && result.includes(\".\")) {\n return (\n result.replace(`.${findFileExtension(result) ?? \"\"}`, \"\") || EMPTY_STRING\n );\n }\n\n return result;\n}\n\n/**\n * Find the full file path's directories from a file path.\n *\n * @remarks\n * The functionality of this method is similar to the {@link path.dirname} function in Node's path module.\n *\n * @example\n * ```ts\n * const folderPath = findFilePath(\"C:\\\\Users\\\\user\\\\Documents\\\\file.txt\");\n * // folderPath = \"C:\\\\Users\\\\user\\\\Documents\"\n * ```\n *\n * @param filePath - The file path to process\n * @param options - Options to control the file name extraction\n * @returns The full file path's directories\n */\nexport function findFilePath(\n filePath: string,\n options: FindFileNameOptions = {}\n): string {\n const normalizedPath = normalizeWindowsPath(filePath);\n\n const result = normalizedPath.replace(\n findFileName(normalizedPath, { requireExtension: false, ...options }),\n \"\"\n );\n\n return result === \"/\" ? result : result.replace(/\\/$/, \"\");\n}\n\nexport const dirname = findFilePath;\n\n/**\n * Find the top most folder containing the file from a file path.\n *\n * @remarks\n * The functionality of this method is similar to the {@link path.basename} function in Node's path module.\n * If you're looking for the full path of the folder (for example: `C:\\\\Users\\\\user\\\\Documents` instead of just `Documents`) containing the file, use {@link findFilePath} instead.\n *\n * @example\n * const folderPath = findFolderName(\"C:\\\\Users\\\\user\\\\Documents\\\\file.txt\");\n * // folderPath = \"Documents\"\n *\n * @param filePath - The file path to process\n * @param options - Options to control the file name extraction\n * @returns The folder containing the file\n */\nexport function findFolderName(\n filePath: string,\n options?: FindFileNameOptions\n): string {\n const segments = findFilePath(filePath, options).split(\"/\");\n\n let lastSegment = \"\";\n for (let i = segments.length - 1; i >= 0; i--) {\n const val = segments[i];\n if (val) {\n lastSegment = val;\n break;\n }\n }\n\n // if (\n // folderPath.lastIndexOf(\"\\\\\") === folderPath.length - 1 ||\n // folderPath.lastIndexOf(\"/\") === folderPath.length - 1\n // ) {\n // folderPath = folderPath.slice(0, Math.max(0, folderPath.length - 1));\n // }\n\n return lastSegment ?? EMPTY_STRING;\n}\n\nexport const basename = findFolderName;\n\n/**\n * Find the file extension from a file path.\n *\n * @remarks\n * The functionality of this method is similar to the {@link path.extname} function in Node's path module.\n * The file extension is the part of the file name that comes after the last dot (`.`) in the file name. If the file name does not contain a dot, or if it ends with a dot, this function will return `undefined`.\n *\n * The returned extension **will not** include the dot, for example `txt` or `js` instead of `.txt` or `.js`.\n *\n * @example\n * ```ts\n * findFileExtension(\"C:\\\\Users\\\\user\\\\Documents\\\\file.config.ts\");\n * // Returns \"ts\"\n * ```\n *\n * @param filePath - The file path to process\n * @returns The file extension or undefined if no extension is found\n */\nexport function findFileExtension(filePath: string): string | undefined {\n if (filePath.endsWith(\".\") || filePath.endsWith(\"/\")) {\n return undefined;\n }\n\n const match = FILE_EXTENSION_REGEX.exec(normalizeWindowsPath(filePath));\n\n return match && match.length > 0 && isSetString(match[0])\n ? match[0].replace(\".\", \"\")\n : undefined;\n}\n\nexport const extname = findFileExtension;\n\n/**\n * Find the file extension including the `\".\"` character prefix from a file path.\n *\n * @remarks\n * The file extension is the part of the file name that comes after (and including) the last dot (`.`) in the file name. If the file name does not contain a dot, or if it ends with a dot, this function will return `undefined`.\n *\n * The returned extension **will** include the dot, for example `.txt` or `.js` instead of `txt` or `js`.\n *\n * @param filePath - The file path to process\n * @returns The file extension (including the `\".\"` prefix) or undefined if no extension is found\n */\nexport function findFileDotExtension(filePath: string): string | undefined {\n const ext = findFileExtension(filePath);\n\n return ext ? `.${ext}` : undefined;\n}\n\n/**\n * Find the file extension from a file path or an empty string.\n *\n * @remarks\n * The file extension is the part of the file name that comes after the last dot (`.`) in the file name. If the file name does not contain a dot, or if it ends with a dot, this function will return `undefined`.\n *\n * The returned extension **will not** include the dot, for example `txt` or `js` instead of `.txt` or `.js`.\n *\n * @param filePath - The file path to process\n * @returns The file extension or an empty string if no extension is found\n */\nexport function findFileExtensionSafe(filePath: string): string {\n return findFileExtension(filePath) ?? EMPTY_STRING;\n}\n\n/**\n * Find the file extension including the `\".\"` character prefix from a file path or an empty string.\n *\n * @remarks\n * The file extension is the part of the file name that comes after (and including) the last dot (`.`) in the file name. If the file name does not contain a dot, or if it ends with a dot, this function will return `undefined`.\n *\n * The returned extension **will** include the dot, for example `.txt` or `.js` instead of `txt` or `js`.\n *\n * @param filePath - The file path to process\n * @returns The file extension (including the `\".\"` prefix) or an empty string if no extension is found\n */\nexport function findFileDotExtensionSafe(filePath: string): string {\n const ext = findFileExtension(filePath);\n\n return ext ? `.${ext}` : \"\";\n}\n\n/**\n * Check if a file path has a file name.\n *\n * @param filePath - The file path to process\n * @returns An indicator specifying if the file path has a file name\n */\nexport function hasFileName(filePath: string): boolean {\n return Boolean(findFileName(filePath));\n}\n\n/**\n * Check if a file path has a file path.\n *\n * @param filePath - The file path to process\n * @returns An indicator specifying if the file path has a file path\n */\nexport function hasFilePath(filePath: string): boolean {\n return Boolean(findFilePath(filePath));\n}\n\n/**\n * Check if a file path has a folder name.\n *\n * @param filePath - The file path to process\n * @returns An indicator specifying if the file path has a folder name\n */\nexport function hasFolderName(filePath: string): boolean {\n return Boolean(findFolderName(filePath));\n}\n\n/**\n * Check if a file path has a file extension.\n *\n * @param filePath - The file path to process\n * @returns An indicator specifying if the file path has a file extension\n */\nexport function hasFileExtension(filePath: string): boolean {\n return Boolean(findFileExtension(filePath));\n}\n\n/**\n * Resolve the file path to an absolute path.\n *\n * @param path - The path to resolve\n * @param cwd - The current working directory\n * @returns The resolved path\n */\nexport function resolvePath(path: string, cwd = currentDir()) {\n // Normalize windows arguments\n const paths = normalizeWindowsPath(path).split(\"/\");\n\n let resolvedPath = \"\";\n let resolvedAbsolute = false;\n\n for (\n let index = paths.length - 1;\n index >= -1 && !resolvedAbsolute;\n index--\n ) {\n const path = index >= 0 ? paths[index] : cwd;\n\n // Skip empty entries\n if (!path || path.length === 0) {\n continue;\n }\n\n resolvedPath = joinPaths(path, resolvedPath);\n resolvedAbsolute = isAbsolutePath(path);\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);\n\n if (resolvedAbsolute && !isAbsolutePath(resolvedPath)) {\n return `/${resolvedPath}`;\n }\n\n return resolvedPath.length > 0 ? resolvedPath : \".\";\n}\n\nexport function resolve(...paths: string[]) {\n // Normalize windows arguments\n paths = paths.map(argument => normalizeWindowsPath(argument));\n\n let resolvedPath = \"\";\n let resolvedAbsolute = false;\n\n for (\n let index = paths.length - 1;\n index >= -1 && !resolvedAbsolute;\n index--\n ) {\n const path = index >= 0 ? paths[index] : currentDir();\n\n // Skip empty entries\n if (!path || path.length === 0) {\n continue;\n }\n\n resolvedPath = `${path}/${resolvedPath}`;\n resolvedAbsolute = isAbsolute(path);\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);\n\n if (resolvedAbsolute && !isAbsolute(resolvedPath)) {\n return `/${resolvedPath}`;\n }\n\n return resolvedPath.length > 0 ? resolvedPath : \".\";\n}\n\n/**\n * Resolve the file path to an absolute path.\n *\n * @param paths - The paths to resolve\n * @returns The resolved path\n */\nexport function resolvePaths(...paths: string[]) {\n return resolvePath(\n joinPaths(...paths.map(path => normalizeWindowsPath(path)))\n );\n}\n\n/**\n * Get the relative path from one file to another.\n *\n * @remarks\n * This function is similar to the `path.relative` function in Node's path module.\n *\n * @param from - The base path to start from\n * @param to - The target path to resolve relative to the base path\n * @returns The relative path from the base path to the target path\n */\nexport function relative(from: string, to: string) {\n // we cast these because `split` will always be at least one string\n const _from = resolve(from).replace(ROOT_FOLDER_REGEX, \"$1\").split(\"/\") as [\n string,\n ...string[]\n ];\n const _to = resolve(to).replace(ROOT_FOLDER_REGEX, \"$1\").split(\"/\") as [\n string,\n ...string[]\n ];\n\n // Different windows drive letters\n if (_to[0][1] === \":\" && _from[0][1] === \":\" && _from[0] !== _to[0]) {\n return _to.join(\"/\");\n }\n\n const _fromCopy = [..._from];\n for (const segment of _fromCopy) {\n if (_to[0] !== segment) {\n break;\n }\n _from.shift();\n _to.shift();\n }\n return [..._from.map(() => \"..\"), ..._to].join(\"/\");\n}\n\n/**\n * Get the relative path from one file to another.\n *\n * @remarks\n * This function wraps the `path.relative` function in Node's path module.\n *\n * @param from - The base path to start from\n * @param to - The target path to resolve relative to the base path\n * @param withEndSlash - Whether to include a trailing slash at the end of the path\n * @returns The relative path from the base path to the target path\n */\nexport function relativePath(from: string, to: string, withEndSlash = false) {\n return relative(\n withEndSlash !== true ? from.replace(/\\/$/, \"\") : from,\n withEndSlash !== true ? to.replace(/\\/$/, \"\") : to\n );\n}\n\n/**\n * Find the file path relative to the workspace root path.\n *\n * @param filePath - The file path to process\n * @returns The resolved file path\n */\nexport function relativeToCurrentDir(filePath: string) {\n return relativePath(filePath, currentDir());\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function parsePath(path: string) {\n // The root of the path such as '/' or 'c:\\'\n const root =\n /^[/\\\\]|^[a-z]:[/\\\\]/i.exec(path)?.[0]?.replace(/\\\\/g, \"/\") || \"\";\n\n const normalizedPath = normalizeWindowsPath(path);\n\n const segments = normalizedPath.replace(/\\/$/, \"\").split(\"/\").slice(0, -1);\n if (segments.length === 1 && /^[A-Z]:$/i.test(segments[0] as string)) {\n segments[0] += \"/\";\n }\n\n const base = findFolderName(normalizedPath);\n const dir = segments.join(\"/\") || (isAbsolutePath(path) ? \"/\" : \".\");\n const ext = findFileExtensionSafe(path);\n\n return {\n root,\n dir,\n base,\n ext,\n name: base.slice(0, base.length - ext.length)\n };\n}\n\n/**\n * Rename the file name with a new name.\n *\n * @param filePath - The current file path being processed\n * @param newFileName - The updated file name being processed\n * @returns The modified or unmodified file path.\n */\nexport function renameFile(filePath: string, newFileName: string): string {\n const file = parsePath(filePath);\n\n return joinPaths(\n file.dir,\n newFileName.includes(\".\") ? newFileName : newFileName + file.ext\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuDA,SAAgB,aACd,UACA,UAA+B,EAAE,EACzB;CACR,MAAM,EAAE,mBAAmB,OAAO,gBAAgB,SAAS;CAC3D,MAAM,SACJ,qBAAqB,SAAS,EAC1B,MAAM,UAAU,SAAS,KAAK,GAAG,OAAO,IAAI,EAC5C,KAAK,IAAI;AAEf,KAAI,qBAAqB,QAAQ,CAAC,OAAO,SAAS,IAAI,CACpD,QAAO;AAGT,KAAI,kBAAkB,SAAS,OAAO,SAAS,IAAI,CACjD,QACE,OAAO,QAAQ,IAAI,kBAAkB,OAAO,IAAI,MAAM,GAAG,IAAI;AAIjE,QAAO;;;;;;;;;;;;;;;;;;AAmBT,SAAgB,aACd,UACA,UAA+B,EAAE,EACzB;CACR,MAAM,iBAAiB,qBAAqB,SAAS;CAErD,MAAM,SAAS,eAAe,QAC5B,aAAa,gBAAgB;EAAE,kBAAkB;EAAO,GAAG;EAAS,CAAC,EACrE,GACD;AAED,QAAO,WAAW,MAAM,SAAS,OAAO,QAAQ,OAAO,GAAG;;;;;;;;;;;;;;;;;AAoB5D,SAAgB,eACd,UACA,SACQ;CACR,MAAM,WAAW,aAAa,UAAU,QAAQ,CAAC,MAAM,IAAI;CAE3D,IAAI,cAAc;AAClB,MAAK,IAAI,IAAI,SAAS,SAAS,GAAG,KAAK,GAAG,KAAK;EAC7C,MAAM,MAAM,SAAS;AACrB,MAAI,KAAK;AACP,iBAAc;AACd;;;AAWJ,QAAO,eAAe;;;;;;;;;;;;;;;;;;;;AAuBxB,SAAgB,kBAAkB,UAAsC;AACtE,KAAI,SAAS,SAAS,IAAI,IAAI,SAAS,SAAS,IAAI,CAClD;CAGF,MAAM,QAAQ,qBAAqB,KAAK,qBAAqB,SAAS,CAAC;AAEvE,QAAO,SAAS,MAAM,SAAS,KAAK,YAAY,MAAM,GAAG,GACrD,MAAM,GAAG,QAAQ,KAAK,GAAG,GACzB;;;;;;;;AA0FN,SAAgB,iBAAiB,UAA2B;AAC1D,QAAO,QAAQ,kBAAkB,SAAS,CAAC;;AA8C7C,SAAgB,QAAQ,GAAG,OAAiB;AAE1C,SAAQ,MAAM,KAAI,aAAY,qBAAqB,SAAS,CAAC;CAE7D,IAAI,eAAe;CACnB,IAAI,mBAAmB;AAEvB,MACE,IAAI,QAAQ,MAAM,SAAS,GAC3B,SAAS,MAAM,CAAC,kBAChB,SACA;EACA,MAAM,OAAO,SAAS,IAAI,MAAM,SAASA,KAAY;AAGrD,MAAI,CAAC,QAAQ,KAAK,WAAW,EAC3B;AAGF,iBAAe,GAAG,KAAK,GAAG;AAC1B,qBAAmB,WAAW,KAAK;;AAOrC,gBAAe,gBAAgB,cAAc,CAAC,iBAAiB;AAE/D,KAAI,oBAAoB,CAAC,WAAW,aAAa,CAC/C,QAAO,IAAI;AAGb,QAAO,aAAa,SAAS,IAAI,eAAe;;;;;;;;;;;;AAyBlD,SAAgB,SAAS,MAAc,IAAY;CAEjD,MAAM,QAAQ,QAAQ,KAAK,CAAC,QAAQ,mBAAmB,KAAK,CAAC,MAAM,IAAI;CAIvE,MAAM,MAAM,QAAQ,GAAG,CAAC,QAAQ,mBAAmB,KAAK,CAAC,MAAM,IAAI;AAMnE,KAAI,IAAI,GAAG,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,MAAM,OAAO,IAAI,GAC/D,QAAO,IAAI,KAAK,IAAI;CAGtB,MAAM,YAAY,CAAC,GAAG,MAAM;AAC5B,MAAK,MAAM,WAAW,WAAW;AAC/B,MAAI,IAAI,OAAO,QACb;AAEF,QAAM,OAAO;AACb,MAAI,OAAO;;AAEb,QAAO,CAAC,GAAG,MAAM,UAAU,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,IAAI;;;;;;;;;;;;;AAcrD,SAAgB,aAAa,MAAc,IAAY,eAAe,OAAO;AAC3E,QAAO,SACL,iBAAiB,OAAO,KAAK,QAAQ,OAAO,GAAG,GAAG,MAClD,iBAAiB,OAAO,GAAG,QAAQ,OAAO,GAAG,GAAG,GACjD"}
@@ -1 +1,32 @@
1
- const e=require(`./slash.cjs`);function t(t,n){let r=e.slash(t.replaceAll(/\\/g,`/`).replace(/\/*$/,``))?.toLowerCase(),i=e.slash(n.replaceAll(/\\/g,`/`).replace(/\/*$/,``))?.toLowerCase();return t!==n&&r!==i&&r.startsWith(`${i}/`)}exports.isParentPath=t;
1
+ const require_slash = require('./slash.cjs');
2
+
3
+ //#region ../path/src/is-parent-path.ts
4
+ /**
5
+ * Check if a given path is a parent of another path.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * isParentPath("/home/user/project/src/index.ts", "/home/user/project/src");
10
+ * // returns true
11
+ * isParentPath("/home/user/project/src/index.ts", "/home/user/project");
12
+ * // returns true
13
+ * isParentPath("/home/user/project/src/index.ts", "/home/user/project/src/other");
14
+ * // returns false
15
+ * isParentPath("/home/user/project/src/index.ts", "/home/user/other");
16
+ * // returns false
17
+ * isParentPath("/home/user/project/src/index.ts", "/home/user/project/src/index.ts");
18
+ * // returns false
19
+ * ```
20
+ *
21
+ * @param childPath - The path to check if it is a child of the parent path.
22
+ * @param parentPath - The path to check if it is a parent of the child path.
23
+ * @returns `true` if `childPath` is a child of `parentPath`, otherwise `false`.
24
+ */
25
+ function isParentPath(childPath, parentPath) {
26
+ const normalizedChild = require_slash.slash(childPath.replaceAll(/\\/g, "/").replace(/\/*$/, ""))?.toLowerCase();
27
+ const normalizedParent = require_slash.slash(parentPath.replaceAll(/\\/g, "/").replace(/\/*$/, ""))?.toLowerCase();
28
+ return childPath !== parentPath && normalizedChild !== normalizedParent && normalizedChild.startsWith(`${normalizedParent}/`);
29
+ }
30
+
31
+ //#endregion
32
+ exports.isParentPath = isParentPath;
@@ -1,2 +1,33 @@
1
- import{slash as e}from"./slash.mjs";function t(t,n){let r=e(t.replaceAll(/\\/g,`/`).replace(/\/*$/,``))?.toLowerCase(),i=e(n.replaceAll(/\\/g,`/`).replace(/\/*$/,``))?.toLowerCase();return t!==n&&r!==i&&r.startsWith(`${i}/`)}export{t as isParentPath};
1
+ import { slash } from "./slash.mjs";
2
+
3
+ //#region ../path/src/is-parent-path.ts
4
+ /**
5
+ * Check if a given path is a parent of another path.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * isParentPath("/home/user/project/src/index.ts", "/home/user/project/src");
10
+ * // returns true
11
+ * isParentPath("/home/user/project/src/index.ts", "/home/user/project");
12
+ * // returns true
13
+ * isParentPath("/home/user/project/src/index.ts", "/home/user/project/src/other");
14
+ * // returns false
15
+ * isParentPath("/home/user/project/src/index.ts", "/home/user/other");
16
+ * // returns false
17
+ * isParentPath("/home/user/project/src/index.ts", "/home/user/project/src/index.ts");
18
+ * // returns false
19
+ * ```
20
+ *
21
+ * @param childPath - The path to check if it is a child of the parent path.
22
+ * @param parentPath - The path to check if it is a parent of the child path.
23
+ * @returns `true` if `childPath` is a child of `parentPath`, otherwise `false`.
24
+ */
25
+ function isParentPath(childPath, parentPath) {
26
+ const normalizedChild = slash(childPath.replaceAll(/\\/g, "/").replace(/\/*$/, ""))?.toLowerCase();
27
+ const normalizedParent = slash(parentPath.replaceAll(/\\/g, "/").replace(/\/*$/, ""))?.toLowerCase();
28
+ return childPath !== parentPath && normalizedChild !== normalizedParent && normalizedChild.startsWith(`${normalizedParent}/`);
29
+ }
30
+
31
+ //#endregion
32
+ export { isParentPath };
2
33
  //# sourceMappingURL=is-parent-path.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-parent-path.mjs","names":[],"sources":["../../../../path/src/is-parent-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 { slash } from \"./slash\";\n\n/**\n * Check if a given path is a parent of another path.\n *\n * @example\n * ```ts\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src\");\n * // returns true\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project\");\n * // returns true\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src/other\");\n * // returns false\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/other\");\n * // returns false\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src/index.ts\");\n * // returns false\n * ```\n *\n * @param childPath - The path to check if it is a child of the parent path.\n * @param parentPath - The path to check if it is a parent of the child path.\n * @returns `true` if `childPath` is a child of `parentPath`, otherwise `false`.\n */\nexport function isParentPath(childPath: string, parentPath: string): boolean {\n const normalizedChild = slash(\n childPath.replaceAll(/\\\\/g, \"/\").replace(/\\/*$/, \"\")\n )?.toLowerCase();\n const normalizedParent = slash(\n parentPath.replaceAll(/\\\\/g, \"/\").replace(/\\/*$/, \"\")\n )?.toLowerCase();\n\n return (\n childPath !== parentPath &&\n normalizedChild !== normalizedParent &&\n normalizedChild.startsWith(`${normalizedParent}/`)\n );\n}\n"],"mappings":"oCAyCA,SAAgB,EAAa,EAAmB,EAA6B,CAC3E,IAAM,EAAkB,EACtB,EAAU,WAAW,MAAO,IAAI,CAAC,QAAQ,OAAQ,GAAG,CACrD,EAAE,aAAa,CACV,EAAmB,EACvB,EAAW,WAAW,MAAO,IAAI,CAAC,QAAQ,OAAQ,GAAG,CACtD,EAAE,aAAa,CAEhB,OACE,IAAc,GACd,IAAoB,GACpB,EAAgB,WAAW,GAAG,EAAiB,GAAG"}
1
+ {"version":3,"file":"is-parent-path.mjs","names":[],"sources":["../../../../path/src/is-parent-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 { slash } from \"./slash\";\n\n/**\n * Check if a given path is a parent of another path.\n *\n * @example\n * ```ts\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src\");\n * // returns true\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project\");\n * // returns true\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src/other\");\n * // returns false\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/other\");\n * // returns false\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src/index.ts\");\n * // returns false\n * ```\n *\n * @param childPath - The path to check if it is a child of the parent path.\n * @param parentPath - The path to check if it is a parent of the child path.\n * @returns `true` if `childPath` is a child of `parentPath`, otherwise `false`.\n */\nexport function isParentPath(childPath: string, parentPath: string): boolean {\n const normalizedChild = slash(\n childPath.replaceAll(/\\\\/g, \"/\").replace(/\\/*$/, \"\")\n )?.toLowerCase();\n const normalizedParent = slash(\n parentPath.replaceAll(/\\\\/g, \"/\").replace(/\\/*$/, \"\")\n )?.toLowerCase();\n\n return (\n childPath !== parentPath &&\n normalizedChild !== normalizedParent &&\n normalizedChild.startsWith(`${normalizedParent}/`)\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,aAAa,WAAmB,YAA6B;CAC3E,MAAM,kBAAkB,MACtB,UAAU,WAAW,OAAO,IAAI,CAAC,QAAQ,QAAQ,GAAG,CACrD,EAAE,aAAa;CAChB,MAAM,mBAAmB,MACvB,WAAW,WAAW,OAAO,IAAI,CAAC,QAAQ,QAAQ,GAAG,CACtD,EAAE,aAAa;AAEhB,QACE,cAAc,cACd,oBAAoB,oBACpB,gBAAgB,WAAW,GAAG,iBAAiB,GAAG"}
@@ -1 +1,14 @@
1
- function e(e){return e===`/`||e===`c:\\`||e===`C:\\`}exports.isSystemRoot=e;
1
+
2
+ //#region ../path/src/is-root-dir.ts
3
+ /**
4
+ * Check if the directory is the current system's root directory.
5
+ *
6
+ * @param dir - The directory to check.
7
+ * @returns Returns true if the directory is the root directory.
8
+ */
9
+ function isSystemRoot(dir) {
10
+ return Boolean(dir === "/" || dir === "c:\\" || dir === "C:\\");
11
+ }
12
+
13
+ //#endregion
14
+ exports.isSystemRoot = isSystemRoot;
@@ -1,2 +1,14 @@
1
- function e(e){return e===`/`||e===`c:\\`||e===`C:\\`}export{e as isSystemRoot};
1
+ //#region ../path/src/is-root-dir.ts
2
+ /**
3
+ * Check if the directory is the current system's root directory.
4
+ *
5
+ * @param dir - The directory to check.
6
+ * @returns Returns true if the directory is the root directory.
7
+ */
8
+ function isSystemRoot(dir) {
9
+ return Boolean(dir === "/" || dir === "c:\\" || dir === "C:\\");
10
+ }
11
+
12
+ //#endregion
13
+ export { isSystemRoot };
2
14
  //# sourceMappingURL=is-root-dir.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-root-dir.mjs","names":[],"sources":["../../../../path/src/is-root-dir.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 * Check if the directory is the current system's root directory.\n *\n * @param dir - The directory to check.\n * @returns Returns true if the directory is the root directory.\n */\nexport function isSystemRoot(dir: string): boolean {\n return Boolean(dir === \"/\" || dir === \"c:\\\\\" || dir === \"C:\\\\\");\n}\n"],"mappings":"AAwBA,SAAgB,EAAa,EAAsB,CACjD,OAAe,IAAQ,KAAO,IAAQ,QAAU,IAAQ"}
1
+ {"version":3,"file":"is-root-dir.mjs","names":[],"sources":["../../../../path/src/is-root-dir.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 * Check if the directory is the current system's root directory.\n *\n * @param dir - The directory to check.\n * @returns Returns true if the directory is the root directory.\n */\nexport function isSystemRoot(dir: string): boolean {\n return Boolean(dir === \"/\" || dir === \"c:\\\\\" || dir === \"C:\\\\\");\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,aAAa,KAAsB;AACjD,QAAO,QAAQ,QAAQ,OAAO,QAAQ,UAAU,QAAQ,OAAO"}
@@ -1 +1,68 @@
1
- const e=require(`./regex.cjs`),t=require(`./slash.cjs`);function n(n){return e.ABSOLUTE_PATH_REGEX.test(t.slash(n))}function r(e){return n(e)}function i(n){return e.NPM_SCOPED_PACKAGE_REGEX.test(t.slash(n))}function a(e){return i(e)}exports.isAbsolute=r,exports.isAbsolutePath=n,exports.isNpmScopedPackage=a;
1
+ const require_regex = require('./regex.cjs');
2
+ const require_slash = require('./slash.cjs');
3
+
4
+ //#region ../path/src/is-type.ts
5
+ /**
6
+ * Check if the path is an absolute path.
7
+ *
8
+ * @param path - The path to check
9
+ * @returns An indicator specifying if the path is an absolute path
10
+ */
11
+ function isAbsolutePath(path) {
12
+ return require_regex.ABSOLUTE_PATH_REGEX.test(require_slash.slash(path));
13
+ }
14
+ /**
15
+ * Check if the path is an absolute path.
16
+ *
17
+ * @remarks
18
+ * This is an alias for {@link isAbsolutePath}.
19
+ *
20
+ * @param path - The path to check
21
+ * @returns An indicator specifying if the path is an absolute path
22
+ */
23
+ function isAbsolute(path) {
24
+ return isAbsolutePath(path);
25
+ }
26
+ /**
27
+ * Check if the path is a npm package path.
28
+ *
29
+ * @remarks
30
+ * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackage}.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * isNpmScopedPackage("@stryke/path"); // returns true
35
+ * isNpmScopedPackage("lodash"); // returns false
36
+ * isNpmNamespacePackage("./src/index.ts"); // returns false
37
+ * ```
38
+ *
39
+ * @param path - The path to check
40
+ * @returns An indicator specifying if the path is a npm package path
41
+ */
42
+ function isNpmScopedPackagePath(path) {
43
+ return require_regex.NPM_SCOPED_PACKAGE_REGEX.test(require_slash.slash(path));
44
+ }
45
+ /**
46
+ * Check if the path is a npm package path.
47
+ *
48
+ * @remarks
49
+ * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackagePath}.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * isNpmScopedPackagePath("@stryke/path"); // returns true
54
+ * isNpmScopedPackagePath("lodash"); // returns false
55
+ * isNpmScopedPackagePath("./src/index.ts"); // returns false
56
+ * ```
57
+ *
58
+ * @param path - The path to check
59
+ * @returns An indicator specifying if the path is a npm package path
60
+ */
61
+ function isNpmScopedPackage(path) {
62
+ return isNpmScopedPackagePath(path);
63
+ }
64
+
65
+ //#endregion
66
+ exports.isAbsolute = isAbsolute;
67
+ exports.isAbsolutePath = isAbsolutePath;
68
+ exports.isNpmScopedPackage = isNpmScopedPackage;
@@ -1,2 +1,67 @@
1
- import{ABSOLUTE_PATH_REGEX as e,NPM_SCOPED_PACKAGE_REGEX as t}from"./regex.mjs";import{slash as n}from"./slash.mjs";function r(t){return e.test(n(t))}function i(e){return r(e)}function a(e){return t.test(n(e))}function o(e){return a(e)}export{i as isAbsolute,r as isAbsolutePath,o as isNpmScopedPackage};
1
+ import { ABSOLUTE_PATH_REGEX, NPM_SCOPED_PACKAGE_REGEX } from "./regex.mjs";
2
+ import { slash } from "./slash.mjs";
3
+
4
+ //#region ../path/src/is-type.ts
5
+ /**
6
+ * Check if the path is an absolute path.
7
+ *
8
+ * @param path - The path to check
9
+ * @returns An indicator specifying if the path is an absolute path
10
+ */
11
+ function isAbsolutePath(path) {
12
+ return ABSOLUTE_PATH_REGEX.test(slash(path));
13
+ }
14
+ /**
15
+ * Check if the path is an absolute path.
16
+ *
17
+ * @remarks
18
+ * This is an alias for {@link isAbsolutePath}.
19
+ *
20
+ * @param path - The path to check
21
+ * @returns An indicator specifying if the path is an absolute path
22
+ */
23
+ function isAbsolute(path) {
24
+ return isAbsolutePath(path);
25
+ }
26
+ /**
27
+ * Check if the path is a npm package path.
28
+ *
29
+ * @remarks
30
+ * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackage}.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * isNpmScopedPackage("@stryke/path"); // returns true
35
+ * isNpmScopedPackage("lodash"); // returns false
36
+ * isNpmNamespacePackage("./src/index.ts"); // returns false
37
+ * ```
38
+ *
39
+ * @param path - The path to check
40
+ * @returns An indicator specifying if the path is a npm package path
41
+ */
42
+ function isNpmScopedPackagePath(path) {
43
+ return NPM_SCOPED_PACKAGE_REGEX.test(slash(path));
44
+ }
45
+ /**
46
+ * Check if the path is a npm package path.
47
+ *
48
+ * @remarks
49
+ * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackagePath}.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * isNpmScopedPackagePath("@stryke/path"); // returns true
54
+ * isNpmScopedPackagePath("lodash"); // returns false
55
+ * isNpmScopedPackagePath("./src/index.ts"); // returns false
56
+ * ```
57
+ *
58
+ * @param path - The path to check
59
+ * @returns An indicator specifying if the path is a npm package path
60
+ */
61
+ function isNpmScopedPackage(path) {
62
+ return isNpmScopedPackagePath(path);
63
+ }
64
+
65
+ //#endregion
66
+ export { isAbsolute, isAbsolutePath, isNpmScopedPackage };
2
67
  //# sourceMappingURL=is-type.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-type.mjs","names":[],"sources":["../../../../path/src/is-type.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 { ABSOLUTE_PATH_REGEX, NPM_SCOPED_PACKAGE_REGEX } from \"./regex\";\nimport { slash } from \"./slash\";\n\n/**\n * Check if the path is an absolute path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolutePath(path: string): boolean {\n return ABSOLUTE_PATH_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is an absolute path.\n *\n * @remarks\n * This is an alias for {@link isAbsolutePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolute(path: string): boolean {\n return isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelativePath(path: string): boolean {\n return !isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @remarks\n * This is an alias for {@link isRelativePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelative(path: string): boolean {\n return isRelativePath(path);\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackage}.\n *\n * @example\n * ```ts\n * isNpmScopedPackage(\"@stryke/path\"); // returns true\n * isNpmScopedPackage(\"lodash\"); // returns false\n * isNpmNamespacePackage(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackagePath(path: string): boolean {\n return NPM_SCOPED_PACKAGE_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackagePath}.\n *\n * @example\n * ```ts\n * isNpmScopedPackagePath(\"@stryke/path\"); // returns true\n * isNpmScopedPackagePath(\"lodash\"); // returns false\n * isNpmScopedPackagePath(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackage(path: string): boolean {\n return isNpmScopedPackagePath(path);\n}\n"],"mappings":"oHA2BA,SAAgB,EAAe,EAAuB,CACpD,OAAO,EAAoB,KAAK,EAAM,EAAK,CAAC,CAY9C,SAAgB,EAAW,EAAuB,CAChD,OAAO,EAAe,EAAK,CA0C7B,SAAgB,EAAuB,EAAuB,CAC5D,OAAO,EAAyB,KAAK,EAAM,EAAK,CAAC,CAmBnD,SAAgB,EAAmB,EAAuB,CACxD,OAAO,EAAuB,EAAK"}
1
+ {"version":3,"file":"is-type.mjs","names":[],"sources":["../../../../path/src/is-type.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 { ABSOLUTE_PATH_REGEX, NPM_SCOPED_PACKAGE_REGEX } from \"./regex\";\nimport { slash } from \"./slash\";\n\n/**\n * Check if the path is an absolute path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolutePath(path: string): boolean {\n return ABSOLUTE_PATH_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is an absolute path.\n *\n * @remarks\n * This is an alias for {@link isAbsolutePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolute(path: string): boolean {\n return isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelativePath(path: string): boolean {\n return !isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @remarks\n * This is an alias for {@link isRelativePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelative(path: string): boolean {\n return isRelativePath(path);\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackage}.\n *\n * @example\n * ```ts\n * isNpmScopedPackage(\"@stryke/path\"); // returns true\n * isNpmScopedPackage(\"lodash\"); // returns false\n * isNpmNamespacePackage(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackagePath(path: string): boolean {\n return NPM_SCOPED_PACKAGE_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackagePath}.\n *\n * @example\n * ```ts\n * isNpmScopedPackagePath(\"@stryke/path\"); // returns true\n * isNpmScopedPackagePath(\"lodash\"); // returns false\n * isNpmScopedPackagePath(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackage(path: string): boolean {\n return isNpmScopedPackagePath(path);\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,eAAe,MAAuB;AACpD,QAAO,oBAAoB,KAAK,MAAM,KAAK,CAAC;;;;;;;;;;;AAY9C,SAAgB,WAAW,MAAuB;AAChD,QAAO,eAAe,KAAK;;;;;;;;;;;;;;;;;;AA0C7B,SAAgB,uBAAuB,MAAuB;AAC5D,QAAO,yBAAyB,KAAK,MAAM,KAAK,CAAC;;;;;;;;;;;;;;;;;;AAmBnD,SAAgB,mBAAmB,MAAuB;AACxD,QAAO,uBAAuB,KAAK"}