@stryke/path 0.0.1

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 (48) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +63 -0
  3. package/dist/index.cjs +38 -0
  4. package/dist/index.d.ts +11 -0
  5. package/dist/index.mjs +1 -0
  6. package/dist/resolve/index.cjs +16 -0
  7. package/dist/resolve/index.d.ts +1 -0
  8. package/dist/resolve/index.mjs +1 -0
  9. package/dist/resolve/resolve.cjs +59 -0
  10. package/dist/resolve/resolve.d.ts +64 -0
  11. package/dist/resolve/resolve.mjs +1 -0
  12. package/dist/utilities/delimiter.cjs +18 -0
  13. package/dist/utilities/delimiter.d.ts +10 -0
  14. package/dist/utilities/delimiter.mjs +1 -0
  15. package/dist/utilities/exists.cjs +12 -0
  16. package/dist/utilities/exists.d.ts +14 -0
  17. package/dist/utilities/exists.mjs +1 -0
  18. package/dist/utilities/file-path-fns.cjs +105 -0
  19. package/dist/utilities/file-path-fns.d.ts +118 -0
  20. package/dist/utilities/file-path-fns.mjs +1 -0
  21. package/dist/utilities/get-parent-path.cjs +27 -0
  22. package/dist/utilities/get-parent-path.d.ts +38 -0
  23. package/dist/utilities/get-parent-path.mjs +1 -0
  24. package/dist/utilities/index.cjs +93 -0
  25. package/dist/utilities/index.d.ts +8 -0
  26. package/dist/utilities/index.mjs +1 -0
  27. package/dist/utilities/is-file.cjs +37 -0
  28. package/dist/utilities/is-file.d.ts +46 -0
  29. package/dist/utilities/is-file.mjs +1 -0
  30. package/dist/utilities/is-root-dir.cjs +8 -0
  31. package/dist/utilities/is-root-dir.d.ts +7 -0
  32. package/dist/utilities/is-root-dir.mjs +1 -0
  33. package/dist/utilities/join-paths.cjs +16 -0
  34. package/dist/utilities/join-paths.d.ts +7 -0
  35. package/dist/utilities/join-paths.mjs +1 -0
  36. package/dist/utilities/normalize-path.cjs +52 -0
  37. package/dist/utilities/normalize-path.d.ts +25 -0
  38. package/dist/utilities/normalize-path.mjs +1 -0
  39. package/dist/workspace/asset-extensions.cjs +7 -0
  40. package/dist/workspace/asset-extensions.d.ts +7 -0
  41. package/dist/workspace/asset-extensions.mjs +1 -0
  42. package/dist/workspace/get-workspace-root.cjs +27 -0
  43. package/dist/workspace/get-workspace-root.d.ts +14 -0
  44. package/dist/workspace/get-workspace-root.mjs +1 -0
  45. package/dist/workspace/index.cjs +27 -0
  46. package/dist/workspace/index.d.ts +2 -0
  47. package/dist/workspace/index.mjs +1 -0
  48. package/package.json +322 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ <!-- START header -->
2
+ <!-- END header -->
3
+
4
+ # Stryke - Path Utilities
5
+
6
+ A package containing various utilities that expand the functionality of
7
+ NodeJs&#39;s \`path\` module
8
+
9
+ <!-- START doctoc -->
10
+ <!-- END doctoc -->
11
+
12
+ ## Installing
13
+
14
+ Using [pnpm](http://pnpm.io):
15
+
16
+ ```bash
17
+ pnpm add -D @stryke/path
18
+ ```
19
+
20
+ <details>
21
+ <summary>Using npm</summary>
22
+
23
+ ```bash
24
+ npm install -D @stryke/path
25
+ ```
26
+
27
+ </details>
28
+
29
+ <details>
30
+ <summary>Using yarn</summary>
31
+
32
+ ```bash
33
+ yarn add -D @stryke/path
34
+ ```
35
+
36
+ </details>
37
+
38
+ ## Reduced Package Size
39
+
40
+ This project uses [tsup](https://tsup.egoist.dev/) to package the source code
41
+ due to its ability to remove unused code and ship smaller javascript files
42
+ thanks to code splitting. This helps to greatly reduce the size of the package
43
+ and to make it easier to use in other projects.
44
+
45
+ ## Development
46
+
47
+ This project is built using [Nx](https://nx.dev). As a result, many of the usual
48
+ commands are available to assist in development.
49
+
50
+ ### Building
51
+
52
+ Run `nx build path` to build the library.
53
+
54
+ ### Running unit tests
55
+
56
+ Run `nx test path` to execute the unit tests via [Jest](https://jestjs.io).
57
+
58
+ ### Linting
59
+
60
+ Run `nx lint path` to run [ESLint](https://eslint.org/) on the package.
61
+
62
+ <!-- START footer -->
63
+ <!-- END footer -->
package/dist/index.cjs ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _resolve = require("./resolve/index.cjs");
7
+ Object.keys(_resolve).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _resolve[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _resolve[key];
14
+ }
15
+ });
16
+ });
17
+ var _utilities = require("./utilities/index.cjs");
18
+ Object.keys(_utilities).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _utilities[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _utilities[key];
25
+ }
26
+ });
27
+ });
28
+ var _workspace = require("./workspace/index.cjs");
29
+ Object.keys(_workspace).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _workspace[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _workspace[key];
36
+ }
37
+ });
38
+ });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The path library used by Storm Software for building NodeJS applications.
3
+ *
4
+ * @remarks
5
+ * A package containing various utilities that expand the functionality of NodeJs's `path` module
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export * from "./resolve";
10
+ export * from "./utilities";
11
+ export * from "./workspace";
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export*from"./resolve";export*from"./utilities";export*from"./workspace";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _resolve = require("./resolve.cjs");
7
+ Object.keys(_resolve).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _resolve[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _resolve[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1 @@
1
+ export * from "./resolve";
@@ -0,0 +1 @@
1
+ export*from"./resolve";
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.importModule = importModule;
7
+ exports.resolve = resolve;
8
+ exports.resolvePackage = resolvePackage;
9
+ exports.resolvePackageSync = resolvePackageSync;
10
+ exports.resolveSafe = resolveSafe;
11
+ exports.resolveSafeSync = resolveSafeSync;
12
+ exports.resolveSync = resolveSync;
13
+ var _mlly = require("mlly");
14
+ var _nodeProcess = _interopRequireDefault(require("node:process"));
15
+ var _utilities = require("../utilities/index.cjs");
16
+ var _getWorkspaceRoot = require("../workspace/get-workspace-root.cjs");
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
+ async function resolve(r, e = {}) {
19
+ const t = e.paths ?? [];
20
+ t.length === 0 && t.push(_nodeProcess.default.cwd());
21
+ const n = (0, _getWorkspaceRoot.getWorkspaceRoot)();
22
+ return t.includes(n) || t.push(n), (0, _utilities.normalizePath)(await (0, _mlly.resolvePath)(r, {
23
+ url: t
24
+ }));
25
+ }
26
+ function resolveSync(r, e = {}) {
27
+ const t = e.paths ?? [];
28
+ t.length === 0 && t.push(_nodeProcess.default.cwd());
29
+ const n = (0, _getWorkspaceRoot.getWorkspaceRoot)();
30
+ return t.includes(n) || t.push(n), (0, _utilities.normalizePath)((0, _mlly.resolvePathSync)(r, {
31
+ url: e.paths
32
+ }));
33
+ }
34
+ function resolveSafe(r, e = {}) {
35
+ try {
36
+ return resolve(r, e);
37
+ } catch {
38
+ return;
39
+ }
40
+ }
41
+ function resolveSafeSync(r, e = {}) {
42
+ try {
43
+ return resolveSync(r, e);
44
+ } catch {
45
+ return;
46
+ }
47
+ }
48
+ async function importModule(r) {
49
+ const e = await Promise.resolve(`${r}`).then(s => require(s));
50
+ return e && (0, _mlly.interopDefault)(e);
51
+ }
52
+ async function resolvePackage(r, e = {}) {
53
+ let t = await resolveSafe((0, _utilities.joinPaths)(r, "package.json"), e);
54
+ return t || (t = await resolveSafe((0, _utilities.joinPaths)(r, "index.js"), e), t || (t = await resolveSafe(r, e))), t;
55
+ }
56
+ async function resolvePackageSync(r, e = {}) {
57
+ let t = await resolveSafeSync((0, _utilities.joinPaths)(r, "package.json"), e);
58
+ return t || (t = await resolveSafeSync((0, _utilities.joinPaths)(r, "index.js"), e), t || (t = await resolveSafeSync(r, e))), t;
59
+ }
@@ -0,0 +1,64 @@
1
+ import type { Platform } from "@stryke/types/utility-types/system";
2
+ export interface PackageResolvingOptions {
3
+ /**
4
+ * Paths to resolve the package from
5
+ */
6
+ paths?: string[];
7
+ /**
8
+ * Resolve path as linux (stand-in for unix/posix) or win32
9
+ */
10
+ platform?: Platform;
11
+ }
12
+ /**
13
+ * Resolve the path to a specified module
14
+ *
15
+ * @param name - The name of the module
16
+ * @param options - The options to use when resolving the module
17
+ * @returns A promise for the path to the module
18
+ */
19
+ export declare function resolve(path: string, options?: PackageResolvingOptions): Promise<string>;
20
+ /**
21
+ * Resolve the path to a specified module
22
+ *
23
+ * @param name - The name of the module
24
+ * @param options - The options to use when resolving the module
25
+ * @returns The path to the module or undefined
26
+ */
27
+ export declare function resolveSync(path: string, options?: PackageResolvingOptions): string;
28
+ /**
29
+ * Resolve the path to a specified module with error handling
30
+ *
31
+ * @param name - The name of the module
32
+ * @param options - The options to use when resolving the module
33
+ * @returns A promise for the path to the module
34
+ */
35
+ export declare function resolveSafe(name: string, options?: PackageResolvingOptions): Promise<string> | undefined;
36
+ /**
37
+ * Resolve the path to a specified module with error handling
38
+ *
39
+ * @param name - The name of the module
40
+ * @param options - The options to use when resolving the module
41
+ * @returns The path to the module or undefined
42
+ */
43
+ export declare function resolveSafeSync(name: string, options?: PackageResolvingOptions): string | undefined;
44
+ /**
45
+ * Import a module from a specified path
46
+ *
47
+ * @param path - The path to the module
48
+ * @returns The module
49
+ */
50
+ export declare function importModule<T = any>(path: string): Promise<T>;
51
+ /**
52
+ * Import a module from a specified path with error handling
53
+ *
54
+ * @param path - The path to the module
55
+ * @returns The module or undefined
56
+ */
57
+ export declare function resolvePackage(name: string, options?: PackageResolvingOptions): Promise<string | undefined>;
58
+ /**
59
+ * Import a module from a specified path with error handling
60
+ *
61
+ * @param path - The path to the module
62
+ * @returns The module or undefined
63
+ */
64
+ export declare function resolvePackageSync(name: string, options?: PackageResolvingOptions): Promise<string | undefined>;
@@ -0,0 +1 @@
1
+ import{interopDefault as c,resolvePath as p,resolvePathSync as l}from"mlly";import s from"node:process";import{joinPaths as o,normalizePath as a}from"../utilities";import{getWorkspaceRoot as i}from"../workspace/get-workspace-root";export async function resolve(r,e={}){const t=e.paths??[];t.length===0&&t.push(s.cwd());const n=i();return t.includes(n)||t.push(n),a(await p(r,{url:t}))}export function resolveSync(r,e={}){const t=e.paths??[];t.length===0&&t.push(s.cwd());const n=i();return t.includes(n)||t.push(n),a(l(r,{url:e.paths}))}export function resolveSafe(r,e={}){try{return resolve(r,e)}catch{return}}export function resolveSafeSync(r,e={}){try{return resolveSync(r,e)}catch{return}}export async function importModule(r){const e=await import(r);return e&&c(e)}export async function resolvePackage(r,e={}){let t=await resolveSafe(o(r,"package.json"),e);return t||(t=await resolveSafe(o(r,"index.js"),e),t||(t=await resolveSafe(r,e))),t}export async function resolvePackageSync(r,e={}){let t=await resolveSafeSync(o(r,"package.json"),e);return t||(t=await resolveSafeSync(o(r,"index.js"),e),t||(t=await resolveSafeSync(r,e))),t}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.win32 = exports.posix = exports.delimiter = void 0;
7
+ const delimiter = exports.delimiter = globalThis.process?.platform === "win32" ? ";" : ":";
8
+ const n = {
9
+ posix: void 0,
10
+ win32: void 0
11
+ },
12
+ o = (t = delimiter) => new Proxy({}, {
13
+ get(i, e) {
14
+ return e === "delimiter" ? t : e === "posix" ? posix : e === "win32" ? win32 : n[e];
15
+ }
16
+ });
17
+ const posix = exports.posix = o(":"),
18
+ win32 = exports.win32 = o(";");
@@ -0,0 +1,10 @@
1
+ type NodePath = typeof import("node:path");
2
+ /**
3
+ * The platform-specific file delimiter.
4
+ *
5
+ * Equals to `";"` in windows and `":"` in all other platforms.
6
+ */
7
+ export declare const delimiter: ";" | ":";
8
+ export declare const posix: NodePath["posix"];
9
+ export declare const win32: NodePath["win32"];
10
+ export {};
@@ -0,0 +1 @@
1
+ export const delimiter=globalThis.process?.platform==="win32"?";":":";const n={posix:void 0,win32:void 0},o=(t=delimiter)=>new Proxy({},{get(i,e){return e==="delimiter"?t:e==="posix"?posix:e==="win32"?win32:n[e]}});export const posix=o(":"),win32=o(";");
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.existsSync = exports.exists = void 0;
7
+ var _nodeFs = require("node:fs");
8
+ var _promises = require("node:fs/promises");
9
+ const existsSync = s => (0, _nodeFs.existsSync)(s),
10
+ exists = s => (0, _promises.access)(s, _promises.constants.F_OK).then(() => !0).catch(() => !1);
11
+ exports.exists = exists;
12
+ exports.existsSync = existsSync;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Check if a file exists
3
+ *
4
+ * @param filePath - The file path to check
5
+ * @returns An indicator specifying if the file exists
6
+ */
7
+ export declare const existsSync: (filePath: string) => boolean;
8
+ /**
9
+ * Check if a file exists
10
+ *
11
+ * @param filePath - The file path to check
12
+ * @returns An indicator specifying if the file exists
13
+ */
14
+ export declare const exists: (filePath: string) => Promise<boolean>;
@@ -0,0 +1 @@
1
+ import{existsSync as t}from"node:fs";import{access as e,constants as n}from"node:fs/promises";export const existsSync=s=>t(s),exists=s=>e(s,n.F_OK).then(()=>!0).catch(()=>!1);
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findFileExtension = findFileExtension;
7
+ exports.findFileName = findFileName;
8
+ exports.findFilePath = findFilePath;
9
+ exports.findFolderName = findFolderName;
10
+ exports.hasFileName = hasFileName;
11
+ exports.hasFilePath = hasFilePath;
12
+ exports.parsePath = parsePath;
13
+ exports.relativePath = relativePath;
14
+ exports.relativeToWorkspaceRoot = relativeToWorkspaceRoot;
15
+ exports.renameFile = renameFile;
16
+ exports.resolvePath = resolvePath;
17
+ exports.resolvePaths = resolvePaths;
18
+ var _base = require("@stryke/types/utility-types/base");
19
+ var _getWorkspaceRoot = require("../workspace/get-workspace-root.cjs");
20
+ var _isFile = require("./is-file.cjs");
21
+ var _joinPaths = require("./join-paths.cjs");
22
+ var _normalizePath = require("./normalize-path.cjs");
23
+ function findFileName(t, {
24
+ requireExtension: e,
25
+ withExtension: r
26
+ } = {}) {
27
+ const n = (0, _normalizePath.normalizeWindowsPath)(t)?.split(t?.includes(_normalizePath.sep) ? _normalizePath.sep : t?.includes("/") ? "/" : "\\")?.pop() ?? "";
28
+ return e === !0 && !n.includes(".") ? _base.EMPTY_STRING : r === !1 && n.includes(".") ? n.split(".").shift() ?? _base.EMPTY_STRING : n;
29
+ }
30
+ function findFilePath(t) {
31
+ const e = (0, _normalizePath.normalizeWindowsPath)(t);
32
+ return e.replace(findFileName(e, {
33
+ requireExtension: !0
34
+ }), "");
35
+ }
36
+ function findFolderName(t) {
37
+ let e = findFilePath(t).split("/"),
38
+ r = "";
39
+ for (let n = e.length - 1; n >= 0; n--) {
40
+ const i = e[n];
41
+ if (i) {
42
+ r = i;
43
+ break;
44
+ }
45
+ }
46
+ return r ?? _base.EMPTY_STRING;
47
+ }
48
+ function findFileExtension(t) {
49
+ if (t === "..") return "";
50
+ const e = /.(\.[^./]+|\.)$/.exec((0, _normalizePath.normalizeWindowsPath)(t));
51
+ return e && e[1] || _base.EMPTY_STRING;
52
+ }
53
+ function hasFileName(t) {
54
+ return !!findFileName(t);
55
+ }
56
+ function hasFilePath(t) {
57
+ return !!findFilePath(t);
58
+ }
59
+ function resolvePath(t, e = (0, _getWorkspaceRoot.getWorkspaceRoot)()) {
60
+ const r = (0, _normalizePath.normalizeWindowsPath)(t).split("/");
61
+ let n = "",
62
+ i = !1;
63
+ for (let o = r.length - 1; o >= -1 && !i; o--) {
64
+ const s = o >= 0 ? r[o] : e;
65
+ !s || s.length === 0 || (n = `${s}/${n}`, i = (0, _isFile.isAbsolutePath)(s));
66
+ }
67
+ return n = (0, _normalizePath.normalizeString)(n, !i), i && !(0, _isFile.isAbsolutePath)(n) ? `/${n}` : n.length > 0 ? n : ".";
68
+ }
69
+ function resolvePaths(...t) {
70
+ return resolvePath((0, _joinPaths.joinPaths)(...t.map(e => (0, _normalizePath.normalizeWindowsPath)(e))));
71
+ }
72
+ function relativePath(t, e) {
73
+ const r = resolvePath(t).replace(/^\/([A-Za-z]:)?$/, "$1").split("/"),
74
+ n = resolvePath(e).replace(/^\/([A-Za-z]:)?$/, "$1").split("/");
75
+ if (n[0][1] === ":" && r[0][1] === ":" && r[0] !== n[0]) return n.join("/");
76
+ const i = [...r];
77
+ for (const o of i) {
78
+ if (n[0] !== o) break;
79
+ r.shift(), n.shift();
80
+ }
81
+ return [...r.map(() => ".."), ...n].join("/");
82
+ }
83
+ function relativeToWorkspaceRoot(t) {
84
+ return relativePath(t, (0, _getWorkspaceRoot.getWorkspaceRoot)());
85
+ }
86
+ function parsePath(t) {
87
+ const e = /^[/\\]|^[a-zA-Z]:[/\\]/.exec(t)?.[0]?.replace(/\\/g, "/") || "",
88
+ r = (0, _normalizePath.normalizeWindowsPath)(t),
89
+ n = r.replace(/\/$/, "").split("/").slice(0, -1);
90
+ n.length === 1 && /^[A-Za-z]:$/.test(n[0]) && (n[0] += "/");
91
+ const i = findFolderName(r),
92
+ o = n.join("/") || ((0, _isFile.isAbsolutePath)(t) ? "/" : "."),
93
+ s = findFileExtension(t);
94
+ return {
95
+ root: e,
96
+ dir: o,
97
+ base: i,
98
+ ext: s,
99
+ name: i.slice(0, i.length - s.length)
100
+ };
101
+ }
102
+ function renameFile(t, e) {
103
+ const r = parsePath(t);
104
+ return (0, _joinPaths.joinPaths)(r.dir, e.includes(".") ? e : e + r.ext);
105
+ }