@stryke/fs 0.33.70 → 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 +17 -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 +139 -58
  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,178 +0,0 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
- const require_cwd = require('./cwd.cjs');
3
- const require_regex = require('./regex.cjs');
4
- const require_is_type = require('./is-type.cjs');
5
- const require_is_set_string = require('../../type-checks/src/is-set-string.cjs');
6
- const require_correct_path = require('./correct-path.cjs');
7
- const require_base = require('../../types/src/base.cjs');
8
- let node_path = require("node:path");
9
- node_path = require_rolldown_runtime.__toESM(node_path);
10
-
11
- //#region ../path/src/file-path-fns.ts
12
- /**
13
- * Find the file name from a file path.
14
- *
15
- * @example
16
- * ```ts
17
- * const fileName = findFileName("C:\\Users\\user\\Documents\\file.txt");
18
- * // fileName = "file.txt"
19
- * ```
20
- *
21
- * @param filePath - The file path to process
22
- * @param options - Options to control the file name extraction
23
- * @returns The file name
24
- */
25
- function findFileName(filePath, options = {}) {
26
- const { requireExtension = false, withExtension = true } = options;
27
- const result = require_correct_path.normalizeWindowsPath(filePath)?.split(filePath?.includes("\\") ? "\\" : "/")?.pop() ?? "";
28
- if (requireExtension === true && !result.includes(".")) return require_base.EMPTY_STRING;
29
- if (withExtension === false && result.includes(".")) return result.replace(`.${findFileExtension(result, options) ?? ""}`, "") || require_base.EMPTY_STRING;
30
- return result;
31
- }
32
- /**
33
- * Find the full file path's directories from a file path.
34
- *
35
- * @remarks
36
- * The functionality of this method is similar to the {@link _path.dirname} function in Node's path module.
37
- *
38
- * @example
39
- * ```ts
40
- * const folderPath = findFilePath("C:\\Users\\user\\Documents\\file.txt");
41
- * // folderPath = "C:\\Users\\user\\Documents"
42
- * ```
43
- *
44
- * @param filePath - The file path to process
45
- * @param options - Options to control the file name extraction
46
- * @returns The full file path's directories
47
- */
48
- function findFilePath(filePath, options = {}) {
49
- const normalizedPath = require_correct_path.normalizeWindowsPath(filePath);
50
- const result = normalizedPath.replace(/* @__PURE__ */ new RegExp(`\/${findFileName(normalizedPath, {
51
- requireExtension: false,
52
- ...options
53
- })}$`), "");
54
- return result === "/" ? result : result.replace(/\/$/, "");
55
- }
56
- /**
57
- * Find the top most folder containing the file from a file path.
58
- *
59
- * @remarks
60
- * The functionality of this method is similar to the {@link _path.basename} function in Node's path module.
61
- * 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.
62
- *
63
- * @example
64
- * const folderPath = findFolderName("C:\\Users\\user\\Documents\\file.txt");
65
- * // folderPath = "Documents"
66
- *
67
- * @param filePath - The file path to process
68
- * @param options - Options to control the file name extraction
69
- * @returns The folder containing the file
70
- */
71
- function findFolderName(filePath, options) {
72
- const segments = findFilePath(filePath, options).split("/");
73
- let lastSegment = "";
74
- for (let i = segments.length - 1; i >= 0; i--) {
75
- const val = segments[i];
76
- if (val) {
77
- lastSegment = val;
78
- break;
79
- }
80
- }
81
- return lastSegment ?? require_base.EMPTY_STRING;
82
- }
83
- /**
84
- * Find the file extension from a file path.
85
- *
86
- * @remarks
87
- * The functionality of this method is similar to the {@link path.extname} function in Node's path module.
88
- * 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`.
89
- *
90
- * The returned extension **will not** include the dot, for example `txt` or `js` instead of `.txt` or `.js`.
91
- *
92
- * @example
93
- * ```ts
94
- * findFileExtension("C:\\Users\\user\\Documents\\file.config.ts"); // Returns "ts"
95
- * findFileExtension("C:\\Users\\user\\Documents\\file.d.ts"); // Returns "ts"
96
- * findFileExtension("C:\\Users\\user\\Documents\\file.d.ts", { fullExtension: true }); // Returns "d.ts"
97
- * findFileExtension("C:\\Users\\user\\Documents\\file.ts.map"); // Returns "ts"
98
- * findFileExtension("C:\\Users\\user\\Documents\\file.ts.map", { fullExtension: true }); // Returns "ts.map"
99
- * findFileExtension("C:\\Users\\user\\Documents\\file"); // Returns undefined
100
- * ```
101
- *
102
- * @param filePath - The file path to process
103
- * @param options - Options to control the file name extraction
104
- * @returns The file extension or undefined if no extension is found
105
- */
106
- function findFileExtension(filePath, options) {
107
- if (filePath.endsWith(".") || filePath.endsWith("/")) return;
108
- const match = (options?.fullExtension ? require_regex.FULL_FILE_EXTENSION_REGEX : require_regex.FILE_EXTENSION_REGEX).exec(require_correct_path.normalizeWindowsPath(filePath));
109
- return match && match.length > 0 && require_is_set_string.isSetString(match[0]) ? match[0].replace(".", "") : void 0;
110
- }
111
- /**
112
- * Check if a file path has a file extension.
113
- *
114
- * @param filePath - The file path to process
115
- * @param options - Options to control the file name extraction
116
- * @returns An indicator specifying if the file path has a file extension
117
- */
118
- function hasFileExtension(filePath, options) {
119
- return Boolean(findFileExtension(filePath, options));
120
- }
121
- function resolve(...paths) {
122
- paths = paths.map((argument) => require_correct_path.normalizeWindowsPath(argument));
123
- let resolvedPath = "";
124
- let resolvedAbsolute = false;
125
- for (let index = paths.length - 1; index >= -1 && !resolvedAbsolute; index--) {
126
- const path = index >= 0 ? paths[index] : require_cwd.cwd();
127
- if (!path || path.length === 0) continue;
128
- resolvedPath = `${path}/${resolvedPath}`;
129
- resolvedAbsolute = require_is_type.isAbsolute(path);
130
- }
131
- resolvedPath = require_correct_path.normalizeString(resolvedPath, !resolvedAbsolute);
132
- if (resolvedAbsolute && !require_is_type.isAbsolute(resolvedPath)) return `/${resolvedPath}`;
133
- return resolvedPath.length > 0 ? resolvedPath : ".";
134
- }
135
- /**
136
- * Get the relative path from one file to another.
137
- *
138
- * @remarks
139
- * This function is similar to the `path.relative` function in Node's path module.
140
- *
141
- * @param from - The base path to start from
142
- * @param to - The target path to resolve relative to the base path
143
- * @returns The relative path from the base path to the target path
144
- */
145
- function relative(from, to) {
146
- const _from = resolve(from).replace(require_regex.ROOT_FOLDER_REGEX, "$1").split("/");
147
- const _to = resolve(to).replace(require_regex.ROOT_FOLDER_REGEX, "$1").split("/");
148
- if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) return _to.join("/");
149
- const _fromCopy = [..._from];
150
- for (const segment of _fromCopy) {
151
- if (_to[0] !== segment) break;
152
- _from.shift();
153
- _to.shift();
154
- }
155
- return [..._from.map(() => ".."), ..._to].join("/");
156
- }
157
- /**
158
- * Get the relative path from one file to another.
159
- *
160
- * @remarks
161
- * This function wraps the `path.relative` function in Node's path module.
162
- *
163
- * @param from - The base path to start from
164
- * @param to - The target path to resolve relative to the base path
165
- * @param withEndSlash - Whether to include a trailing slash at the end of the path
166
- * @returns The relative path from the base path to the target path
167
- */
168
- function relativePath(from, to, withEndSlash = false) {
169
- return relative(withEndSlash !== true ? from.replace(/\/$/, "") : from, withEndSlash !== true ? to.replace(/\/$/, "") : to);
170
- }
171
-
172
- //#endregion
173
- exports.findFileExtension = findFileExtension;
174
- exports.findFileName = findFileName;
175
- exports.findFilePath = findFilePath;
176
- exports.findFolderName = findFolderName;
177
- exports.hasFileExtension = hasFileExtension;
178
- exports.relativePath = relativePath;
@@ -1,171 +0,0 @@
1
- import { cwd } from "./cwd.mjs";
2
- import { FILE_EXTENSION_REGEX, FULL_FILE_EXTENSION_REGEX, ROOT_FOLDER_REGEX } from "./regex.mjs";
3
- import { isAbsolute } from "./is-type.mjs";
4
- import { isSetString } from "../../type-checks/src/is-set-string.mjs";
5
- import { normalizeString, normalizeWindowsPath } from "./correct-path.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, options) ?? ""}`, "") || 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(/* @__PURE__ */ new RegExp(`\/${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"); // Returns "ts"
92
- * findFileExtension("C:\\Users\\user\\Documents\\file.d.ts"); // Returns "ts"
93
- * findFileExtension("C:\\Users\\user\\Documents\\file.d.ts", { fullExtension: true }); // Returns "d.ts"
94
- * findFileExtension("C:\\Users\\user\\Documents\\file.ts.map"); // Returns "ts"
95
- * findFileExtension("C:\\Users\\user\\Documents\\file.ts.map", { fullExtension: true }); // Returns "ts.map"
96
- * findFileExtension("C:\\Users\\user\\Documents\\file"); // Returns undefined
97
- * ```
98
- *
99
- * @param filePath - The file path to process
100
- * @param options - Options to control the file name extraction
101
- * @returns The file extension or undefined if no extension is found
102
- */
103
- function findFileExtension(filePath, options) {
104
- if (filePath.endsWith(".") || filePath.endsWith("/")) return;
105
- const match = (options?.fullExtension ? FULL_FILE_EXTENSION_REGEX : FILE_EXTENSION_REGEX).exec(normalizeWindowsPath(filePath));
106
- return match && match.length > 0 && isSetString(match[0]) ? match[0].replace(".", "") : void 0;
107
- }
108
- /**
109
- * Check if a file path has a file extension.
110
- *
111
- * @param filePath - The file path to process
112
- * @param options - Options to control the file name extraction
113
- * @returns An indicator specifying if the file path has a file extension
114
- */
115
- function hasFileExtension(filePath, options) {
116
- return Boolean(findFileExtension(filePath, options));
117
- }
118
- function resolve(...paths) {
119
- paths = paths.map((argument) => normalizeWindowsPath(argument));
120
- let resolvedPath = "";
121
- let resolvedAbsolute = false;
122
- for (let index = paths.length - 1; index >= -1 && !resolvedAbsolute; index--) {
123
- const path = index >= 0 ? paths[index] : cwd();
124
- if (!path || path.length === 0) continue;
125
- resolvedPath = `${path}/${resolvedPath}`;
126
- resolvedAbsolute = isAbsolute(path);
127
- }
128
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
129
- if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
130
- return resolvedPath.length > 0 ? resolvedPath : ".";
131
- }
132
- /**
133
- * Get the relative path from one file to another.
134
- *
135
- * @remarks
136
- * This function is similar to the `path.relative` function in Node's path module.
137
- *
138
- * @param from - The base path to start from
139
- * @param to - The target path to resolve relative to the base path
140
- * @returns The relative path from the base path to the target path
141
- */
142
- function relative(from, to) {
143
- const _from = resolve(from).replace(ROOT_FOLDER_REGEX, "$1").split("/");
144
- const _to = resolve(to).replace(ROOT_FOLDER_REGEX, "$1").split("/");
145
- if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) return _to.join("/");
146
- const _fromCopy = [..._from];
147
- for (const segment of _fromCopy) {
148
- if (_to[0] !== segment) break;
149
- _from.shift();
150
- _to.shift();
151
- }
152
- return [..._from.map(() => ".."), ..._to].join("/");
153
- }
154
- /**
155
- * Get the relative path from one file to another.
156
- *
157
- * @remarks
158
- * This function wraps the `path.relative` function in Node's path module.
159
- *
160
- * @param from - The base path to start from
161
- * @param to - The target path to resolve relative to the base path
162
- * @param withEndSlash - Whether to include a trailing slash at the end of the path
163
- * @returns The relative path from the base path to the target path
164
- */
165
- function relativePath(from, to, withEndSlash = false) {
166
- return relative(withEndSlash !== true ? from.replace(/\/$/, "") : from, withEndSlash !== true ? to.replace(/\/$/, "") : to);
167
- }
168
-
169
- //#endregion
170
- export { findFileExtension, findFileName, findFilePath, findFolderName, hasFileExtension, relativePath };
171
- //# sourceMappingURL=file-path-fns.mjs.map
@@ -1 +0,0 @@
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 _path from \"node:path\";\nimport { normalizeString, normalizeWindowsPath } from \"./correct-path\";\nimport { cwd as currentDir } from \"./cwd\";\nimport { isAbsolute, isAbsolutePath } from \"./is-type\";\nimport { joinPaths } from \"./join-paths\";\nimport {\n FILE_EXTENSION_REGEX,\n FULL_FILE_EXTENSION_REGEX,\n ROOT_FOLDER_REGEX\n} from \"./regex\";\n\nexport interface FindFileNameOptions extends FindFileExtensionOptions {\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, options) ?? \"\"}`, \"\") ||\n 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 new RegExp(\n `\\/${findFileName(normalizedPath, { requireExtension: false, ...options })}$`\n ),\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\nexport interface FindFileExtensionOptions {\n /**\n * Return the full file extension including `.d` and `.map` if present.\n *\n * @defaultValue false\n */\n fullExtension?: boolean;\n}\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\"); // Returns \"ts\"\n * findFileExtension(\"C:\\\\Users\\\\user\\\\Documents\\\\file.d.ts\"); // Returns \"ts\"\n * findFileExtension(\"C:\\\\Users\\\\user\\\\Documents\\\\file.d.ts\", { fullExtension: true }); // Returns \"d.ts\"\n * findFileExtension(\"C:\\\\Users\\\\user\\\\Documents\\\\file.ts.map\"); // Returns \"ts\"\n * findFileExtension(\"C:\\\\Users\\\\user\\\\Documents\\\\file.ts.map\", { fullExtension: true }); // Returns \"ts.map\"\n * findFileExtension(\"C:\\\\Users\\\\user\\\\Documents\\\\file\"); // Returns undefined\n * ```\n *\n * @param filePath - The file path to process\n * @param options - Options to control the file name extraction\n * @returns The file extension or undefined if no extension is found\n */\nexport function findFileExtension(\n filePath: string,\n options?: FindFileExtensionOptions\n): string | undefined {\n if (filePath.endsWith(\".\") || filePath.endsWith(\"/\")) {\n return undefined;\n }\n\n const match = (\n options?.fullExtension ? FULL_FILE_EXTENSION_REGEX : FILE_EXTENSION_REGEX\n ).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 * @param options - Options to control the file name extraction\n * @returns The file extension (including the `\".\"` prefix) or undefined if no extension is found\n */\nexport function findFileDotExtension(\n filePath: string,\n options?: FindFileExtensionOptions\n): string | undefined {\n const ext = findFileExtension(filePath, options);\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 * @param options - Options to control the file name extraction\n * @returns The file extension or an empty string if no extension is found\n */\nexport function findFileExtensionSafe(\n filePath: string,\n options?: FindFileExtensionOptions\n): string {\n return findFileExtension(filePath, options) ?? 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 * @param options - Options to control the file name extraction\n * @returns The file extension (including the `\".\"` prefix) or an empty string if no extension is found\n */\nexport function findFileDotExtensionSafe(\n filePath: string,\n options?: FindFileExtensionOptions\n): string {\n const ext = findFileExtension(filePath, options);\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 * @param options - Options to control the file name extraction\n * @returns An indicator specifying if the file path has a file extension\n */\nexport function hasFileExtension(\n filePath: string,\n options?: FindFileExtensionOptions\n): boolean {\n return Boolean(findFileExtension(filePath, options));\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, options?: FindFileNameOptions) {\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, options);\n const dir = segments.join(\"/\") || (isAbsolutePath(path) ? \"/\" : \".\");\n const ext = findFileExtensionSafe(path, options);\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 * @param options - Options to control the file name extraction\n * @returns The modified or unmodified file path.\n */\nexport function renameFile(\n filePath: string,\n newFileName: string,\n options?: FindFileNameOptions\n): string {\n const file = parsePath(filePath, options);\n\n return joinPaths(\n file.dir,\n newFileName.includes(\".\") ? newFileName : newFileName + file.ext\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4DA,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,QAAQ,QAAQ,IAAI,MAAM,GAAG,IAClE;AAIJ,QAAO;;;;;;;;;;;;;;;;;;AAmBT,SAAgB,aACd,UACA,UAA+B,EAAE,EACzB;CACR,MAAM,iBAAiB,qBAAqB,SAAS;CAErD,MAAM,SAAS,eAAe,wBAC5B,IAAI,OACF,KAAK,aAAa,gBAAgB;EAAE,kBAAkB;EAAO,GAAG;EAAS,CAAC,CAAC,GAC5E,EACD,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;;;;;;;;;;;;;;;;;;;;;;;;;AAqCxB,SAAgB,kBACd,UACA,SACoB;AACpB,KAAI,SAAS,SAAS,IAAI,IAAI,SAAS,SAAS,IAAI,CAClD;CAGF,MAAM,SACJ,SAAS,gBAAgB,4BAA4B,sBACrD,KAAK,qBAAqB,SAAS,CAAC;AAEtC,QAAO,SAAS,MAAM,SAAS,KAAK,YAAY,MAAM,GAAG,GACrD,MAAM,GAAG,QAAQ,KAAK,GAAG,GACzB;;;;;;;;;AAuGN,SAAgB,iBACd,UACA,SACS;AACT,QAAO,QAAQ,kBAAkB,UAAU,QAAQ,CAAC;;AA8CtD,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,32 +0,0 @@
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,33 +0,0 @@
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 };
33
- //# sourceMappingURL=is-parent-path.mjs.map
@@ -1 +0,0 @@
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,14 +0,0 @@
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,14 +0,0 @@
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 };
14
- //# sourceMappingURL=is-root-dir.mjs.map
@@ -1 +0,0 @@
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,68 +0,0 @@
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,67 +0,0 @@
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 };
67
- //# sourceMappingURL=is-type.mjs.map
@@ -1 +0,0 @@
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"}