@stryke/path 0.4.10 → 0.4.12

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.
package/README.md CHANGED
@@ -22,7 +22,7 @@ This package is part of Storm Software's **đŸŒŠī¸ Stryke** monorepo. Stryke pac
22
22
 
23
23
  <h3 align="center">đŸ’ģ Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
24
24
 
25
- [![Version](https://img.shields.io/badge/version-0.4.7-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/stryke/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
25
+ [![Version](https://img.shields.io/badge/version-0.4.11-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/stryke/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
26
26
 
27
27
  > [!IMPORTANT] This repository, and the apps, libraries, and tools contained
28
28
  > within, is still in it's initial development phase. As a result, bugs and
@@ -6,51 +6,46 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.correctPath = correctPath;
7
7
  exports.normalizeString = normalizeString;
8
8
  exports.normalizeWindowsPath = normalizeWindowsPath;
9
- exports.slash = slash;
10
9
  var _isFile = require("./is-file.cjs");
11
- function slash(e) {
12
- return e.replace(/\\/g, "/");
13
- }
14
- const c = /^[A-Z]:\//i;
10
+ var _regex = require("./regex.cjs");
11
+ var _slash = require("./slash.cjs");
15
12
  function normalizeWindowsPath(e = "") {
16
- return e && e.replace(/\\/g, "/").replace(c, s => s.toUpperCase());
13
+ return e && (0, _slash.slash)(e).replace(_regex.DRIVE_LETTER_START_REGEX, s => s.toUpperCase());
17
14
  }
18
- const u = /^[/\\]{2}/,
19
- E = /^[A-Z]:$/i;
20
15
  function correctPath(e) {
21
16
  if (!e || e.length === 0) return ".";
22
17
  e = normalizeWindowsPath(e);
23
- const s = e.match(u),
18
+ const s = e.match(_regex.UNC_REGEX),
24
19
  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 += "/"), s ? n ? `//${e}` : `//./${e}` : n && !(0, _isFile.isAbsolutePath)(e) ? `/${e}` : e);
20
+ l = e.endsWith("/");
21
+ return e = normalizeString(e, !n), e.length === 0 ? n ? "/" : l ? "./" : "." : (l && (e += "/"), _regex.DRIVE_LETTER_REGEX.test(e) && (e += "/"), s ? n ? `//${e}` : `//./${e}` : !e.startsWith("/") && n && !_regex.DRIVE_LETTER_REGEX.test(e) ? `/${e}` : e);
27
22
  }
28
23
  function normalizeString(e, s) {
29
24
  let n = "",
30
- t = 0,
25
+ l = 0,
31
26
  i = -1,
32
27
  r = 0,
33
28
  o = null;
34
- for (let l = 0; l <= e.length; ++l) {
35
- if (l < e.length) o = e[l];else {
29
+ for (let t = 0; t <= e.length; ++t) {
30
+ if (t < e.length) o = e[t];else {
36
31
  if (o === "/") break;
37
32
  o = "/";
38
33
  }
39
34
  if (o === "/") {
40
- if (!(i === l - 1 || r === 1)) if (r === 2) {
41
- if (n.length < 2 || t !== 2 || n[n.length - 1] !== "." || n[n.length - 2] !== ".") {
35
+ if (!(i === t - 1 || r === 1)) if (r === 2) {
36
+ if (n.length < 2 || l !== 2 || n[n.length - 1] !== "." || n[n.length - 2] !== ".") {
42
37
  if (n.length > 2) {
43
38
  const f = n.lastIndexOf("/");
44
- f === -1 ? (n = "", t = 0) : (n = n.slice(0, f), t = n.length - 1 - n.lastIndexOf("/")), i = l, r = 0;
39
+ f === -1 ? (n = "", l = 0) : (n = n.slice(0, f), l = n.length - 1 - n.lastIndexOf("/")), i = t, r = 0;
45
40
  continue;
46
41
  } else if (n.length > 0) {
47
- n = "", t = 0, i = l, r = 0;
42
+ n = "", l = 0, i = t, r = 0;
48
43
  continue;
49
44
  }
50
45
  }
51
- s && (n += n.length > 0 ? "/.." : "..", t = 2);
52
- } else n.length > 0 ? n += `/${e.slice(i + 1, l)}` : n = e.slice(i + 1, l), t = l - i - 1;
53
- i = l, r = 0;
46
+ s && (n += n.length > 0 ? "/.." : "..", l = 2);
47
+ } else n.length > 0 ? n += `/${e.slice(i + 1, t)}` : n = e.slice(i + 1, t), l = t - i - 1;
48
+ i = t, r = 0;
54
49
  } else o === "." && r !== -1 ? ++r : r = -1;
55
50
  }
56
51
  return n;
@@ -1,10 +1,3 @@
1
- /**
2
- * Replace backslash to slash
3
- *
4
- * @param str - The string to replace
5
- * @returns The string with replaced backslashes
6
- */
7
- export declare function slash(str: string): string;
8
1
  export declare function normalizeWindowsPath(input?: string): string;
9
2
  /**
10
3
  * Corrects/normalized a file path.
@@ -1 +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,s=>s.toUpperCase())}const u=/^[/\\]{2}/,E=/^[A-Z]:$/i;export function correctPath(e){if(!e||e.length===0)return".";e=normalizeWindowsPath(e);const s=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+="/"),s?n?`//${e}`:`//./${e}`:n&&!g(e)?`/${e}`:e)}export function normalizeString(e,s){let n="",t=0,i=-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(!(i===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("/")),i=l,r=0;continue}else if(n.length>0){n="",t=0,i=l,r=0;continue}}s&&(n+=n.length>0?"/..":"..",t=2)}else n.length>0?n+=`/${e.slice(i+1,l)}`:n=e.slice(i+1,l),t=l-i-1;i=l,r=0}else o==="."&&r!==-1?++r:r=-1}return n}
1
+ import{isAbsolutePath as c}from"./is-file";import{DRIVE_LETTER_REGEX as g,DRIVE_LETTER_START_REGEX as u,UNC_REGEX as E}from"./regex";import{slash as m}from"./slash";export function normalizeWindowsPath(e=""){return e&&m(e).replace(u,s=>s.toUpperCase())}export function correctPath(e){if(!e||e.length===0)return".";e=normalizeWindowsPath(e);const s=e.match(E),n=c(e),l=e.endsWith("/");return e=normalizeString(e,!n),e.length===0?n?"/":l?"./":".":(l&&(e+="/"),g.test(e)&&(e+="/"),s?n?`//${e}`:`//./${e}`:!e.startsWith("/")&&n&&!g.test(e)?`/${e}`:e)}export function normalizeString(e,s){let n="",l=0,i=-1,r=0,o=null;for(let t=0;t<=e.length;++t){if(t<e.length)o=e[t];else{if(o==="/")break;o="/"}if(o==="/"){if(!(i===t-1||r===1))if(r===2){if(n.length<2||l!==2||n[n.length-1]!=="."||n[n.length-2]!=="."){if(n.length>2){const f=n.lastIndexOf("/");f===-1?(n="",l=0):(n=n.slice(0,f),l=n.length-1-n.lastIndexOf("/")),i=t,r=0;continue}else if(n.length>0){n="",l=0,i=t,r=0;continue}}s&&(n+=n.length>0?"/..":"..",l=2)}else n.length>0?n+=`/${e.slice(i+1,t)}`:n=e.slice(i+1,t),l=t-i-1;i=t,r=0}else o==="."&&r!==-1?++r:r=-1}return n}
package/dist/index.cjs CHANGED
@@ -113,6 +113,17 @@ Object.keys(_joinPaths).forEach(function (key) {
113
113
  }
114
114
  });
115
115
  });
116
+ var _regex = require("./regex.cjs");
117
+ Object.keys(_regex).forEach(function (key) {
118
+ if (key === "default" || key === "__esModule") return;
119
+ if (key in exports && exports[key] === _regex[key]) return;
120
+ Object.defineProperty(exports, key, {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _regex[key];
124
+ }
125
+ });
126
+ });
116
127
  var _resolve = require("./resolve.cjs");
117
128
  Object.keys(_resolve).forEach(function (key) {
118
129
  if (key === "default" || key === "__esModule") return;
@@ -123,4 +134,15 @@ Object.keys(_resolve).forEach(function (key) {
123
134
  return _resolve[key];
124
135
  }
125
136
  });
137
+ });
138
+ var _slash = require("./slash.cjs");
139
+ Object.keys(_slash).forEach(function (key) {
140
+ if (key === "default" || key === "__esModule") return;
141
+ if (key in exports && exports[key] === _slash[key]) return;
142
+ Object.defineProperty(exports, key, {
143
+ enumerable: true,
144
+ get: function () {
145
+ return _slash[key];
146
+ }
147
+ });
126
148
  });
package/dist/index.d.ts CHANGED
@@ -16,4 +16,6 @@ export * from "./get-workspace-root";
16
16
  export * from "./is-file";
17
17
  export * from "./is-root-dir";
18
18
  export * from "./join-paths";
19
+ export * from "./regex";
19
20
  export * from "./resolve";
21
+ export * from "./slash";
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export*from"./asset-extensions";export*from"./correct-path";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"./resolve";
1
+ export*from"./asset-extensions";export*from"./correct-path";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"./regex";export*from"./resolve";export*from"./slash";
package/dist/is-file.cjs CHANGED
@@ -11,6 +11,8 @@ exports.isFileSymlink = void 0;
11
11
  exports.isRelativePath = isRelativePath;
12
12
  var _nodeFs = require("node:fs");
13
13
  var _joinPaths = require("./join-paths.cjs");
14
+ var _regex = require("./regex.cjs");
15
+ var _slash = require("./slash.cjs");
14
16
  function isFile(r, o) {
15
17
  return !!(0, _nodeFs.statSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
16
18
  throwIfNoEntry: !1
@@ -29,9 +31,9 @@ const isFileSymlink = (r, o) => !!(0, _nodeFs.lstatSync)(o ? (0, _joinPaths.join
29
31
  })?.isDirectory();
30
32
  exports.isDirectorySymlink = isDirectorySymlink;
31
33
  exports.isFileSymlink = isFileSymlink;
32
- function isRelativePath(r) {
33
- return r === "." || r === ".." || r.startsWith("./") || r.startsWith("../");
34
- }
35
34
  function isAbsolutePath(r) {
36
- return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(r);
35
+ return _regex.ABSOLUTE_PATH_REGEX.test((0, _slash.slash)(r));
36
+ }
37
+ function isRelativePath(r) {
38
+ return !isAbsolutePath(r);
37
39
  }
package/dist/is-file.d.ts CHANGED
@@ -31,16 +31,16 @@ export declare const isFileSymlink: (path: string, additionalPath?: string) => b
31
31
  */
32
32
  export declare const isDirectorySymlink: (path: string, additionalPath?: string) => boolean;
33
33
  /**
34
- * Check if the path is a relative path.
34
+ * Check if the path is an absolute path.
35
35
  *
36
36
  * @param path - The path to check
37
- * @returns An indicator specifying if the path is a relative path
37
+ * @returns An indicator specifying if the path is an absolute path
38
38
  */
39
- export declare function isRelativePath(path: string): boolean;
39
+ export declare function isAbsolutePath(path: string): boolean;
40
40
  /**
41
- * Check if the path is an absolute path.
41
+ * Check if the path is a relative path.
42
42
  *
43
43
  * @param path - The path to check
44
- * @returns An indicator specifying if the path is an absolute path
44
+ * @returns An indicator specifying if the path is a relative path
45
45
  */
46
- export declare function isAbsolutePath(path: string): boolean;
46
+ export declare function isRelativePath(path: string): boolean;
package/dist/is-file.mjs CHANGED
@@ -1 +1 @@
1
- import{lstatSync as n,statSync as e}from"node:fs";import{joinPaths as t}from"./join-paths";export function isFile(r,o){return!!e(o?t(o,r):r,{throwIfNoEntry:!1})?.isFile()}export function isDirectory(r,o){return!!e(o?t(o,r):r,{throwIfNoEntry:!1})?.isDirectory()}export const isFileSymlink=(r,o)=>!!n(o?t(o,r):r,{throwIfNoEntry:!1})?.isFile(),isDirectorySymlink=(r,o)=>!!n(o?t(o,r):r,{throwIfNoEntry:!1})?.isDirectory();export function isRelativePath(r){return r==="."||r===".."||r.startsWith("./")||r.startsWith("../")}export function isAbsolutePath(r){return!/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(r)}
1
+ import{lstatSync as n,statSync as e}from"node:fs";import{joinPaths as t}from"./join-paths";import{ABSOLUTE_PATH_REGEX as s}from"./regex";import{slash as i}from"./slash";export function isFile(r,o){return!!e(o?t(o,r):r,{throwIfNoEntry:!1})?.isFile()}export function isDirectory(r,o){return!!e(o?t(o,r):r,{throwIfNoEntry:!1})?.isDirectory()}export const isFileSymlink=(r,o)=>!!n(o?t(o,r):r,{throwIfNoEntry:!1})?.isFile(),isDirectorySymlink=(r,o)=>!!n(o?t(o,r):r,{throwIfNoEntry:!1})?.isDirectory();export function isAbsolutePath(r){return s.test(i(r))}export function isRelativePath(r){return!isAbsolutePath(r)}
package/dist/regex.cjs ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UNC_REGEX = exports.DRIVE_LETTER_START_REGEX = exports.DRIVE_LETTER_REGEX = exports.ABSOLUTE_PATH_REGEX = void 0;
7
+ const DRIVE_LETTER_START_REGEX = exports.DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i,
8
+ DRIVE_LETTER_REGEX = exports.DRIVE_LETTER_REGEX = /^[A-Z]:$/i,
9
+ UNC_REGEX = exports.UNC_REGEX = /^[/\\]{2}/,
10
+ ABSOLUTE_PATH_REGEX = exports.ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
@@ -0,0 +1,4 @@
1
+ export declare const DRIVE_LETTER_START_REGEX: RegExp;
2
+ export declare const DRIVE_LETTER_REGEX: RegExp;
3
+ export declare const UNC_REGEX: RegExp;
4
+ export declare const ABSOLUTE_PATH_REGEX: RegExp;
package/dist/regex.mjs ADDED
@@ -0,0 +1 @@
1
+ export const DRIVE_LETTER_START_REGEX=/^[A-Z]:\//i,DRIVE_LETTER_REGEX=/^[A-Z]:$/i,UNC_REGEX=/^[/\\]{2}/,ABSOLUTE_PATH_REGEX=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
package/dist/slash.cjs ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.slash = slash;
7
+ function slash(r) {
8
+ return r.replace(/\\/g, "/");
9
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Replace backslash to slash
3
+ *
4
+ * @param str - The string to replace
5
+ * @returns The string with replaced backslashes
6
+ */
7
+ export declare function slash(str: string): string;
package/dist/slash.mjs ADDED
@@ -0,0 +1 @@
1
+ export function slash(r){return r.replace(/\\/g,"/")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/path",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "type": "module",
5
5
  "description": "A package containing various utilities that expand the functionality of NodeJs's built-in `path` module",
6
6
  "repository": {
@@ -55,6 +55,14 @@
55
55
  }
56
56
  ],
57
57
  "exports": {
58
+ "./slash": {
59
+ "import": { "types": "./dist/slash.d.ts", "default": "./dist/slash.mjs" },
60
+ "require": {
61
+ "types": "./dist/slash.d.ts",
62
+ "default": "./dist/slash.cjs"
63
+ },
64
+ "default": { "types": "./dist/slash.d.ts", "default": "./dist/slash.mjs" }
65
+ },
58
66
  "./resolve": {
59
67
  "import": {
60
68
  "types": "./dist/resolve.d.ts",
@@ -69,6 +77,14 @@
69
77
  "default": "./dist/resolve.mjs"
70
78
  }
71
79
  },
80
+ "./regex": {
81
+ "import": { "types": "./dist/regex.d.ts", "default": "./dist/regex.mjs" },
82
+ "require": {
83
+ "types": "./dist/regex.d.ts",
84
+ "default": "./dist/regex.cjs"
85
+ },
86
+ "default": { "types": "./dist/regex.d.ts", "default": "./dist/regex.mjs" }
87
+ },
72
88
  "./join-paths": {
73
89
  "import": {
74
90
  "types": "./dist/join-paths.d.ts",