@stryke/path 0.3.1 → 0.3.4

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 (53) hide show
  1. package/dist/file-path-fns.cjs +105 -0
  2. package/dist/{utilities/file-path-fns.d.ts → file-path-fns.d.ts} +1 -1
  3. package/dist/file-path-fns.mjs +1 -0
  4. package/dist/{workspace/get-workspace-root.cjs → get-workspace-root.cjs} +3 -3
  5. package/dist/get-workspace-root.mjs +1 -0
  6. package/dist/index.cjs +100 -12
  7. package/dist/index.d.ts +10 -2
  8. package/dist/index.mjs +1 -1
  9. package/dist/join-paths.cjs +17 -0
  10. package/dist/join-paths.d.ts +11 -0
  11. package/dist/join-paths.mjs +1 -0
  12. package/dist/{utilities/normalize-path.cjs → normalize-path.cjs} +23 -21
  13. package/dist/{utilities/normalize-path.d.ts → normalize-path.d.ts} +2 -17
  14. package/dist/normalize-path.mjs +1 -0
  15. package/dist/{resolve/resolve.cjs → resolve.cjs} +2 -2
  16. package/dist/{resolve/resolve.d.ts → resolve.d.ts} +7 -7
  17. package/package.json +83 -168
  18. package/dist/resolve/index.cjs +0 -16
  19. package/dist/resolve/index.d.ts +0 -1
  20. package/dist/resolve/index.mjs +0 -1
  21. package/dist/utilities/file-path-fns.cjs +0 -105
  22. package/dist/utilities/file-path-fns.mjs +0 -1
  23. package/dist/utilities/index.cjs +0 -93
  24. package/dist/utilities/index.d.ts +0 -8
  25. package/dist/utilities/index.mjs +0 -1
  26. package/dist/utilities/join-paths.cjs +0 -16
  27. package/dist/utilities/join-paths.d.ts +0 -7
  28. package/dist/utilities/join-paths.mjs +0 -1
  29. package/dist/utilities/normalize-path.mjs +0 -1
  30. package/dist/workspace/get-workspace-root.mjs +0 -1
  31. package/dist/workspace/index.cjs +0 -27
  32. package/dist/workspace/index.d.ts +0 -2
  33. package/dist/workspace/index.mjs +0 -1
  34. /package/dist/{workspace/asset-extensions.cjs → asset-extensions.cjs} +0 -0
  35. /package/dist/{workspace/asset-extensions.d.ts → asset-extensions.d.ts} +0 -0
  36. /package/dist/{workspace/asset-extensions.mjs → asset-extensions.mjs} +0 -0
  37. /package/dist/{utilities/delimiter.cjs → delimiter.cjs} +0 -0
  38. /package/dist/{utilities/delimiter.d.ts → delimiter.d.ts} +0 -0
  39. /package/dist/{utilities/delimiter.mjs → delimiter.mjs} +0 -0
  40. /package/dist/{utilities/exists.cjs → exists.cjs} +0 -0
  41. /package/dist/{utilities/exists.d.ts → exists.d.ts} +0 -0
  42. /package/dist/{utilities/exists.mjs → exists.mjs} +0 -0
  43. /package/dist/{utilities/get-parent-path.cjs → get-parent-path.cjs} +0 -0
  44. /package/dist/{utilities/get-parent-path.d.ts → get-parent-path.d.ts} +0 -0
  45. /package/dist/{utilities/get-parent-path.mjs → get-parent-path.mjs} +0 -0
  46. /package/dist/{workspace/get-workspace-root.d.ts → get-workspace-root.d.ts} +0 -0
  47. /package/dist/{utilities/is-file.cjs → is-file.cjs} +0 -0
  48. /package/dist/{utilities/is-file.d.ts → is-file.d.ts} +0 -0
  49. /package/dist/{utilities/is-file.mjs → is-file.mjs} +0 -0
  50. /package/dist/{utilities/is-root-dir.cjs → is-root-dir.cjs} +0 -0
  51. /package/dist/{utilities/is-root-dir.d.ts → is-root-dir.d.ts} +0 -0
  52. /package/dist/{utilities/is-root-dir.mjs → is-root-dir.mjs} +0 -0
  53. /package/dist/{resolve/resolve.mjs → resolve.mjs} +0 -0
@@ -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/base");
19
+ var _getWorkspaceRoot = require("../workspace/get-workspace-root");
20
+ var _isFile = require("./is-file.cjs");
21
+ var _joinPaths = require("./join-paths.cjs");
22
+ var _normalizePath = require("./normalize-path.cjs");
23
+ function findFileName(n, {
24
+ requireExtension: e,
25
+ withExtension: r
26
+ } = {}) {
27
+ const t = (0, _normalizePath.normalizeWindowsPath)(n)?.split(n?.includes("\\") ? "\\" : "/")?.pop() ?? "";
28
+ return e === !0 && !t.includes(".") ? _base.EMPTY_STRING : r === !1 && t.includes(".") ? t.split(".").slice(-1).join(".") || _base.EMPTY_STRING : t;
29
+ }
30
+ function findFilePath(n) {
31
+ const e = (0, _normalizePath.normalizeWindowsPath)(n);
32
+ return e.replace(findFileName(e, {
33
+ requireExtension: !0
34
+ }), "");
35
+ }
36
+ function findFolderName(n) {
37
+ const e = findFilePath(n).split("/");
38
+ let r = "";
39
+ for (let t = e.length - 1; t >= 0; t--) {
40
+ const i = e[t];
41
+ if (i) {
42
+ r = i;
43
+ break;
44
+ }
45
+ }
46
+ return r ?? _base.EMPTY_STRING;
47
+ }
48
+ function findFileExtension(n) {
49
+ if (n === "..") return "";
50
+ const e = /.(\.[^./]+|\.)$/.exec((0, _normalizePath.normalizeWindowsPath)(n));
51
+ return e && e[1] || _base.EMPTY_STRING;
52
+ }
53
+ function hasFileName(n) {
54
+ return !!findFileName(n);
55
+ }
56
+ function hasFilePath(n) {
57
+ return !!findFilePath(n);
58
+ }
59
+ function resolvePath(n, e = (0, _getWorkspaceRoot.getWorkspaceRoot)()) {
60
+ const r = (0, _normalizePath.normalizeWindowsPath)(n).split("/");
61
+ let t = "",
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 || (t = (0, _joinPaths.joinPaths)(s, t), i = (0, _isFile.isAbsolutePath)(s));
66
+ }
67
+ return t = (0, _normalizePath.normalizeString)(t, !i), i && !(0, _isFile.isAbsolutePath)(t) ? `/${t}` : t.length > 0 ? t : ".";
68
+ }
69
+ function resolvePaths(...n) {
70
+ return resolvePath((0, _joinPaths.joinPaths)(...n.map(e => (0, _normalizePath.normalizeWindowsPath)(e))));
71
+ }
72
+ function relativePath(n, e) {
73
+ const r = resolvePath(n).replace(/^\/([A-Z]:)?$/i, "$1").split("/"),
74
+ t = resolvePath(e).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
75
+ if (t[0][1] === ":" && r[0][1] === ":" && r[0] !== t[0]) return t.join("/");
76
+ const i = [...r];
77
+ for (const o of i) {
78
+ if (t[0] !== o) break;
79
+ r.shift(), t.shift();
80
+ }
81
+ return [...r.map(() => ".."), ...t].join("/");
82
+ }
83
+ function relativeToWorkspaceRoot(n) {
84
+ return relativePath(n, (0, _getWorkspaceRoot.getWorkspaceRoot)());
85
+ }
86
+ function parsePath(n) {
87
+ const e = /^[/\\]|^[a-z]:[/\\]/i.exec(n)?.[0]?.replace(/\\/g, "/") || "",
88
+ r = (0, _normalizePath.normalizeWindowsPath)(n),
89
+ t = r.replace(/\/$/, "").split("/").slice(0, -1);
90
+ t.length === 1 && /^[A-Z]:$/i.test(t[0]) && (t[0] += "/");
91
+ const i = findFolderName(r),
92
+ o = t.join("/") || ((0, _isFile.isAbsolutePath)(n) ? "/" : "."),
93
+ s = findFileExtension(n);
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(n, e) {
103
+ const r = parsePath(n);
104
+ return (0, _joinPaths.joinPaths)(r.dir, e.includes(".") ? e : e + r.ext);
105
+ }
@@ -83,7 +83,7 @@ export declare function hasFilePath(filePath: string): boolean;
83
83
  * @param cwd - The current working directory
84
84
  * @returns The resolved path
85
85
  */
86
- export declare function resolvePath(path: string, cwd?: string): string;
86
+ export declare function resolvePath(path: string, cwd?: any): string;
87
87
  /**
88
88
  * Resolve the file path to an absolute path.
89
89
  *
@@ -0,0 +1 @@
1
+ import{EMPTY_STRING as a}from"@stryke/types/base";import{getWorkspaceRoot as f}from"../workspace/get-workspace-root";import{isAbsolutePath as c}from"./is-file";import{joinPaths as u}from"./join-paths";import{normalizeString as p,normalizeWindowsPath as l}from"./normalize-path";export function findFileName(n,{requireExtension:e,withExtension:r}={}){const t=l(n)?.split(n?.includes("\\")?"\\":"/")?.pop()??"";return e===!0&&!t.includes(".")?a:r===!1&&t.includes(".")?t.split(".").slice(-1).join(".")||a:t}export function findFilePath(n){const e=l(n);return e.replace(findFileName(e,{requireExtension:!0}),"")}export function findFolderName(n){const e=findFilePath(n).split("/");let r="";for(let t=e.length-1;t>=0;t--){const i=e[t];if(i){r=i;break}}return r??a}export function findFileExtension(n){if(n==="..")return"";const e=/.(\.[^./]+|\.)$/.exec(l(n));return e&&e[1]||a}export function hasFileName(n){return!!findFileName(n)}export function hasFilePath(n){return!!findFilePath(n)}export function resolvePath(n,e=f()){const r=l(n).split("/");let t="",i=!1;for(let o=r.length-1;o>=-1&&!i;o--){const s=o>=0?r[o]:e;!s||s.length===0||(t=u(s,t),i=c(s))}return t=p(t,!i),i&&!c(t)?`/${t}`:t.length>0?t:"."}export function resolvePaths(...n){return resolvePath(u(...n.map(e=>l(e))))}export function relativePath(n,e){const r=resolvePath(n).replace(/^\/([A-Z]:)?$/i,"$1").split("/"),t=resolvePath(e).replace(/^\/([A-Z]:)?$/i,"$1").split("/");if(t[0][1]===":"&&r[0][1]===":"&&r[0]!==t[0])return t.join("/");const i=[...r];for(const o of i){if(t[0]!==o)break;r.shift(),t.shift()}return[...r.map(()=>".."),...t].join("/")}export function relativeToWorkspaceRoot(n){return relativePath(n,f())}export function parsePath(n){const e=/^[/\\]|^[a-z]:[/\\]/i.exec(n)?.[0]?.replace(/\\/g,"/")||"",r=l(n),t=r.replace(/\/$/,"").split("/").slice(0,-1);t.length===1&&/^[A-Z]:$/i.test(t[0])&&(t[0]+="/");const i=findFolderName(r),o=t.join("/")||(c(n)?"/":"."),s=findFileExtension(n);return{root:e,dir:o,base:i,ext:s,name:i.slice(0,i.length-s.length)}}export function renameFile(n,e){const r=parsePath(n);return u(r.dir,e.includes(".")?e:e+r.ext)}
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getWorkspaceRoot = exports.getProjectRoot = void 0;
7
7
  var _configTools = require("@storm-software/config-tools");
8
- var _packageManager = require("@stryke/types/utility-types/package-manager");
9
- var _getParentPath = require("../utilities/get-parent-path.cjs");
10
- var _isRootDir = require("../utilities/is-root-dir.cjs");
8
+ var _packageManager = require("@stryke/types/package-manager");
9
+ var _getParentPath = require("./get-parent-path.cjs");
10
+ var _isRootDir = require("./is-root-dir.cjs");
11
11
  const getWorkspaceRoot = (r = process.cwd()) => {
12
12
  if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH;
13
13
  const t = (0, _configTools.findWorkspaceRootSafe)(r);
@@ -0,0 +1 @@
1
+ import{findWorkspaceRootSafe as c}from"@storm-software/config-tools";import{PackageManagerLockFiles as e}from"@stryke/types/package-manager";import{getParentPath as s}from"./get-parent-path";import{isSystemRoot as n}from"./is-root-dir";export const getWorkspaceRoot=(r=process.cwd())=>{if(process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH)return process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH;const t=c(r);if(t)return t;let o=s([e.NPM,e.YARN,e.PNPM,e.BUN,"nx.json","knip.json","pnpm-workspace.yaml","LICENSE",".all-contributorsrc",".whitesource","syncpack.config.js","syncpack.json","socket.yaml","lefthook.yaml",".npmrc",".log4brains.yml",".huskyrc",".husky",".lintstagedrc",".commitlintrc","lefthook.yml",".github",".nx",".vscode","patches"],r);if(o)return o;for(o=r;o&&!n(o);)if(o=s("storm.json",o,{skipCwd:!0}),o)return o;return r},getProjectRoot=(r=process.cwd())=>{const t=s(["project.json","package.json",".storm"],r);return t||r};
package/dist/index.cjs CHANGED
@@ -3,36 +3,124 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _resolve = require("./resolve/index.cjs");
7
- Object.keys(_resolve).forEach(function (key) {
6
+ var _assetExtensions = require("./asset-extensions.cjs");
7
+ Object.keys(_assetExtensions).forEach(function (key) {
8
8
  if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _resolve[key]) return;
9
+ if (key in exports && exports[key] === _assetExtensions[key]) return;
10
10
  Object.defineProperty(exports, key, {
11
11
  enumerable: true,
12
12
  get: function () {
13
- return _resolve[key];
13
+ return _assetExtensions[key];
14
+ }
15
+ });
16
+ });
17
+ var _delimiter = require("./delimiter.cjs");
18
+ Object.keys(_delimiter).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _delimiter[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _delimiter[key];
25
+ }
26
+ });
27
+ });
28
+ var _exists = require("./exists.cjs");
29
+ Object.keys(_exists).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _exists[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _exists[key];
36
+ }
37
+ });
38
+ });
39
+ var _filePathFns = require("./file-path-fns.cjs");
40
+ Object.keys(_filePathFns).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _filePathFns[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _filePathFns[key];
47
+ }
48
+ });
49
+ });
50
+ var _getParentPath = require("./get-parent-path.cjs");
51
+ Object.keys(_getParentPath).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _getParentPath[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _getParentPath[key];
14
58
  }
15
59
  });
16
60
  });
17
- var _utilities = require("./utilities/index.cjs");
18
- Object.keys(_utilities).forEach(function (key) {
61
+ var _getWorkspaceRoot = require("./get-workspace-root.cjs");
62
+ Object.keys(_getWorkspaceRoot).forEach(function (key) {
19
63
  if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _utilities[key]) return;
64
+ if (key in exports && exports[key] === _getWorkspaceRoot[key]) return;
21
65
  Object.defineProperty(exports, key, {
22
66
  enumerable: true,
23
67
  get: function () {
24
- return _utilities[key];
68
+ return _getWorkspaceRoot[key];
25
69
  }
26
70
  });
27
71
  });
28
- var _workspace = require("./workspace/index.cjs");
29
- Object.keys(_workspace).forEach(function (key) {
72
+ var _isFile = require("./is-file.cjs");
73
+ Object.keys(_isFile).forEach(function (key) {
30
74
  if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _workspace[key]) return;
75
+ if (key in exports && exports[key] === _isFile[key]) return;
32
76
  Object.defineProperty(exports, key, {
33
77
  enumerable: true,
34
78
  get: function () {
35
- return _workspace[key];
79
+ return _isFile[key];
80
+ }
81
+ });
82
+ });
83
+ var _isRootDir = require("./is-root-dir.cjs");
84
+ Object.keys(_isRootDir).forEach(function (key) {
85
+ if (key === "default" || key === "__esModule") return;
86
+ if (key in exports && exports[key] === _isRootDir[key]) return;
87
+ Object.defineProperty(exports, key, {
88
+ enumerable: true,
89
+ get: function () {
90
+ return _isRootDir[key];
91
+ }
92
+ });
93
+ });
94
+ var _joinPaths = require("./join-paths.cjs");
95
+ Object.keys(_joinPaths).forEach(function (key) {
96
+ if (key === "default" || key === "__esModule") return;
97
+ if (key in exports && exports[key] === _joinPaths[key]) return;
98
+ Object.defineProperty(exports, key, {
99
+ enumerable: true,
100
+ get: function () {
101
+ return _joinPaths[key];
102
+ }
103
+ });
104
+ });
105
+ var _normalizePath = require("./normalize-path.cjs");
106
+ Object.keys(_normalizePath).forEach(function (key) {
107
+ if (key === "default" || key === "__esModule") return;
108
+ if (key in exports && exports[key] === _normalizePath[key]) return;
109
+ Object.defineProperty(exports, key, {
110
+ enumerable: true,
111
+ get: function () {
112
+ return _normalizePath[key];
113
+ }
114
+ });
115
+ });
116
+ var _resolve = require("./resolve.cjs");
117
+ Object.keys(_resolve).forEach(function (key) {
118
+ if (key === "default" || key === "__esModule") return;
119
+ if (key in exports && exports[key] === _resolve[key]) return;
120
+ Object.defineProperty(exports, key, {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _resolve[key];
36
124
  }
37
125
  });
38
126
  });
package/dist/index.d.ts CHANGED
@@ -6,6 +6,14 @@
6
6
  *
7
7
  * @packageDocumentation
8
8
  */
9
+ export * from "./asset-extensions";
10
+ export * from "./delimiter";
11
+ export * from "./exists";
12
+ export * from "./file-path-fns";
13
+ export * from "./get-parent-path";
14
+ export * from "./get-workspace-root";
15
+ export * from "./is-file";
16
+ export * from "./is-root-dir";
17
+ export * from "./join-paths";
18
+ export * from "./normalize-path";
9
19
  export * from "./resolve";
10
- export * from "./utilities";
11
- export * from "./workspace";
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export*from"./resolve";export*from"./utilities";export*from"./workspace";
1
+ export*from"./asset-extensions";export*from"./delimiter";export*from"./exists";export*from"./file-path-fns";export*from"./get-parent-path";export*from"./get-workspace-root";export*from"./is-file";export*from"./is-root-dir";export*from"./join-paths";export*from"./normalize-path";export*from"./resolve";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.joinPaths = void 0;
7
+ var _normalizePath = require("./normalize-path.cjs");
8
+ const joinPaths = (...i) => {
9
+ let t = "";
10
+ for (const o of i) if (o) if (t.length > 0) {
11
+ const e = t[t.length - 1] === "/",
12
+ n = o[0] === "/";
13
+ e && n ? t += o.slice(1) : t += e || n ? o : `/${o}`;
14
+ } else t += o;
15
+ return (0, _normalizePath.correctPaths)(t);
16
+ };
17
+ exports.joinPaths = joinPaths;
@@ -0,0 +1,11 @@
1
+ import type path from "node:path";
2
+ /**
3
+ * Join multiple path segments together, resolving '.' and '..' segments, and normalizing the resulting path.
4
+ *
5
+ * @remarks
6
+ * This helper utility performs string joining similar to the `node:path` module's `join` function, and then normalizes the resulting path.
7
+ *
8
+ * @param segments - The path segments to join.
9
+ * @returns The joined path string.
10
+ */
11
+ export declare const joinPaths: typeof path.join;
@@ -0,0 +1 @@
1
+ import{correctPaths as s}from"./normalize-path";export const joinPaths=(...i)=>{let t="";for(const o of i)if(o)if(t.length>0){const e=t[t.length-1]==="/",n=o[0]==="/";e&&n?t+=o.slice(1):t+=e||n?o:`/${o}`}else t+=o;return s(t)};
@@ -3,23 +3,33 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.normalizePath = normalizePath;
6
+ exports.correctPaths = void 0;
7
7
  exports.normalizeString = normalizeString;
8
8
  exports.normalizeWindowsPath = normalizeWindowsPath;
9
- exports.sep = void 0;
10
9
  exports.slash = slash;
11
10
  var _isFile = require("./is-file.cjs");
12
11
  function slash(e) {
13
12
  return e.replace(/\\/g, "/");
14
13
  }
14
+ const c = /^[A-Z]:\//i;
15
15
  function normalizeWindowsPath(e = "") {
16
- return e && e.replace(/\\/g, "/").replace(/^[A-Z]:\//i, s => s.toUpperCase());
16
+ return e && e.replace(/\\/g, "/").replace(c, i => i.toUpperCase());
17
17
  }
18
- const sep = exports.sep = "/";
19
- function normalizeString(e, s) {
18
+ const u = /^[/\\]{2}/,
19
+ E = /^[A-Z]:$/i;
20
+ const correctPaths = e => {
21
+ if (!e || e.length === 0) return ".";
22
+ e = normalizeWindowsPath(e);
23
+ const i = e.match(u),
24
+ n = (0, _isFile.isAbsolutePath)(e),
25
+ t = e[e.length - 1] === "/";
26
+ return e = normalizeString(e, !n), e.length === 0 ? n ? "/" : t ? "./" : "." : (t && (e += "/"), E.test(e) && (e += "/"), i ? n ? `//${e}` : `//./${e}` : n && !(0, _isFile.isAbsolutePath)(e) ? `/${e}` : e);
27
+ };
28
+ exports.correctPaths = correctPaths;
29
+ function normalizeString(e, i) {
20
30
  let n = "",
21
31
  t = 0,
22
- i = -1,
32
+ s = -1,
23
33
  r = 0,
24
34
  o = null;
25
35
  for (let l = 0; l <= e.length; ++l) {
@@ -28,29 +38,21 @@ function normalizeString(e, s) {
28
38
  o = "/";
29
39
  }
30
40
  if (o === "/") {
31
- if (!(i === l - 1 || r === 1)) if (r === 2) {
32
- if (n.length < 2 || t !== 2 || n.at(-1) !== "." || n.at(-2) !== ".") {
41
+ if (!(s === l - 1 || r === 1)) if (r === 2) {
42
+ if (n.length < 2 || t !== 2 || n[n.length - 1] !== "." || n[n.length - 2] !== ".") {
33
43
  if (n.length > 2) {
34
44
  const f = n.lastIndexOf("/");
35
- f === -1 ? (n = "", t = 0) : (n = n.slice(0, f), t = n.length - 1 - n.lastIndexOf("/")), i = l, r = 0;
45
+ f === -1 ? (n = "", t = 0) : (n = n.slice(0, f), t = n.length - 1 - n.lastIndexOf("/")), s = l, r = 0;
36
46
  continue;
37
47
  } else if (n.length > 0) {
38
- n = "", t = 0, i = l, r = 0;
48
+ n = "", t = 0, s = l, r = 0;
39
49
  continue;
40
50
  }
41
51
  }
42
- s && (n += n.length > 0 ? "/.." : "..", t = 2);
43
- } else n.length > 0 ? n += `/${e.slice(i + 1, l)}` : n = e.slice(i + 1, l), t = l - i - 1;
44
- i = l, r = 0;
52
+ i && (n += n.length > 0 ? "/.." : "..", t = 2);
53
+ } else n.length > 0 ? n += `/${e.slice(s + 1, l)}` : n = e.slice(s + 1, l), t = l - s - 1;
54
+ s = l, r = 0;
45
55
  } else o === "." && r !== -1 ? ++r : r = -1;
46
56
  }
47
57
  return n;
48
- }
49
- function normalizePath(e) {
50
- if (!e || e.length === 0) return ".";
51
- e = normalizeWindowsPath(e);
52
- const s = e.match(/^[/\\]{2}/),
53
- n = (0, _isFile.isAbsolutePath)(e),
54
- t = e.at(-1) === "/";
55
- return e = normalizeString(e, !n), e.length === 0 ? n ? "/" : t ? "./" : "." : (t && (e += "/"), /^[A-Z]:$/i.test(e) && (e += "/"), s ? n ? `//${e}` : `//./${e}` : n && !(0, _isFile.isAbsolutePath)(e) ? `/${e}` : e);
56
58
  }
@@ -6,27 +6,12 @@
6
6
  */
7
7
  export declare function slash(str: string): string;
8
8
  export declare function normalizeWindowsPath(input?: string): string;
9
- /**
10
- * Constant for path separator.
11
- *
12
- * Always equals to `"/"`.
13
- */
14
- export declare const sep = "/";
9
+ export declare const correctPaths: (path?: string) => string;
15
10
  /**
16
11
  * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
17
12
  *
18
13
  * @param path - The path to normalize.
19
14
  * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
20
- * @returns the normalized path string.
15
+ * @returns the normalize path string.
21
16
  */
22
17
  export declare function normalizeString(path: string, allowAboveRoot: boolean): string;
23
- /**
24
- * Normalizes the given path.
25
- *
26
- * @remarks
27
- * Removes duplicate slashes, removes trailing slashes, adds a leading slash.
28
- *
29
- * @param path - The path to normalize
30
- * @returns The normalized path
31
- */
32
- export declare function normalizePath(path?: string): string;
@@ -0,0 +1 @@
1
+ import{isAbsolutePath as g}from"./is-file";export function slash(e){return e.replace(/\\/g,"/")}const c=/^[A-Z]:\//i;export function normalizeWindowsPath(e=""){return e&&e.replace(/\\/g,"/").replace(c,i=>i.toUpperCase())}const u=/^[/\\]{2}/,E=/^[A-Z]:$/i;export const correctPaths=e=>{if(!e||e.length===0)return".";e=normalizeWindowsPath(e);const i=e.match(u),n=g(e),t=e[e.length-1]==="/";return e=normalizeString(e,!n),e.length===0?n?"/":t?"./":".":(t&&(e+="/"),E.test(e)&&(e+="/"),i?n?`//${e}`:`//./${e}`:n&&!g(e)?`/${e}`:e)};export function normalizeString(e,i){let n="",t=0,s=-1,r=0,o=null;for(let l=0;l<=e.length;++l){if(l<e.length)o=e[l];else{if(o==="/")break;o="/"}if(o==="/"){if(!(s===l-1||r===1))if(r===2){if(n.length<2||t!==2||n[n.length-1]!=="."||n[n.length-2]!=="."){if(n.length>2){const f=n.lastIndexOf("/");f===-1?(n="",t=0):(n=n.slice(0,f),t=n.length-1-n.lastIndexOf("/")),s=l,r=0;continue}else if(n.length>0){n="",t=0,s=l,r=0;continue}}i&&(n+=n.length>0?"/..":"..",t=2)}else n.length>0?n+=`/${e.slice(s+1,l)}`:n=e.slice(s+1,l),t=l-s-1;s=l,r=0}else o==="."&&r!==-1?++r:r=-1}return n}
@@ -12,8 +12,8 @@ exports.resolveSafeSync = resolveSafeSync;
12
12
  exports.resolveSync = resolveSync;
13
13
  var _mlly = require("mlly");
14
14
  var _nodeProcess = _interopRequireDefault(require("node:process"));
15
- var _utilities = require("../utilities/index.cjs");
16
- var _getWorkspaceRoot = require("../workspace/get-workspace-root.cjs");
15
+ var _utilities = require("../utilities");
16
+ var _getWorkspaceRoot = require("../workspace/get-workspace-root");
17
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
18
  async function resolve(r, e = {}) {
19
19
  const t = e.paths ?? [];
@@ -1,4 +1,4 @@
1
- import type { Platform } from "@stryke/types/utility-types/system";
1
+ import type { Platform } from "@stryke/types/system";
2
2
  export interface PackageResolvingOptions {
3
3
  /**
4
4
  * Paths to resolve the package from
@@ -16,7 +16,7 @@ export interface PackageResolvingOptions {
16
16
  * @param options - The options to use when resolving the module
17
17
  * @returns A promise for the path to the module
18
18
  */
19
- export declare function resolve(path: string, options?: PackageResolvingOptions): Promise<string>;
19
+ export declare function resolve(path: string, options?: PackageResolvingOptions): Promise<any>;
20
20
  /**
21
21
  * Resolve the path to a specified module
22
22
  *
@@ -24,7 +24,7 @@ export declare function resolve(path: string, options?: PackageResolvingOptions)
24
24
  * @param options - The options to use when resolving the module
25
25
  * @returns The path to the module or undefined
26
26
  */
27
- export declare function resolveSync(path: string, options?: PackageResolvingOptions): string;
27
+ export declare function resolveSync(path: string, options?: PackageResolvingOptions): any;
28
28
  /**
29
29
  * Resolve the path to a specified module with error handling
30
30
  *
@@ -32,7 +32,7 @@ export declare function resolveSync(path: string, options?: PackageResolvingOpti
32
32
  * @param options - The options to use when resolving the module
33
33
  * @returns A promise for the path to the module
34
34
  */
35
- export declare function resolveSafe(name: string, options?: PackageResolvingOptions): Promise<string> | undefined;
35
+ export declare function resolveSafe(name: string, options?: PackageResolvingOptions): Promise<any> | undefined;
36
36
  /**
37
37
  * Resolve the path to a specified module with error handling
38
38
  *
@@ -40,7 +40,7 @@ export declare function resolveSafe(name: string, options?: PackageResolvingOpti
40
40
  * @param options - The options to use when resolving the module
41
41
  * @returns The path to the module or undefined
42
42
  */
43
- export declare function resolveSafeSync(name: string, options?: PackageResolvingOptions): string | undefined;
43
+ export declare function resolveSafeSync(name: string, options?: PackageResolvingOptions): any;
44
44
  /**
45
45
  * Import a module from a specified path
46
46
  *
@@ -54,11 +54,11 @@ export declare function importModule<T = any>(path: string): Promise<T>;
54
54
  * @param path - The path to the module
55
55
  * @returns The module or undefined
56
56
  */
57
- export declare function resolvePackage(name: string, options?: PackageResolvingOptions): Promise<string | undefined>;
57
+ export declare function resolvePackage(name: string, options?: PackageResolvingOptions): Promise<any>;
58
58
  /**
59
59
  * Import a module from a specified path with error handling
60
60
  *
61
61
  * @param path - The path to the module
62
62
  * @returns The module or undefined
63
63
  */
64
- export declare function resolvePackageSync(name: string, options?: PackageResolvingOptions): Promise<string | undefined>;
64
+ export declare function resolvePackageSync(name: string, options?: PackageResolvingOptions): Promise<any>;