@stryke/path 0.25.0 → 0.25.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.
- package/CHANGELOG.md +7 -0
- package/dist/append.cjs +59 -1
- package/dist/append.mjs +57 -1
- package/dist/append.mjs.map +1 -1
- package/dist/asset-extensions.cjs +40 -1
- package/dist/asset-extensions.mjs +39 -1
- package/dist/asset-extensions.mjs.map +1 -1
- package/dist/common.cjs +34 -1
- package/dist/common.mjs +34 -1
- package/dist/common.mjs.map +1 -1
- package/dist/correct-path.cjs +176 -1
- package/dist/correct-path.mjs +169 -1
- package/dist/correct-path.mjs.map +1 -1
- package/dist/cwd.cjs +17 -1
- package/dist/cwd.mjs +16 -1
- package/dist/cwd.mjs.map +1 -1
- package/dist/delimiter.cjs +27 -1
- package/dist/delimiter.mjs +24 -1
- package/dist/delimiter.mjs.map +1 -1
- package/dist/file-path-fns.cjs +332 -1
- package/dist/file-path-fns.mjs +311 -1
- package/dist/file-path-fns.mjs.map +1 -1
- package/dist/find.cjs +24 -1
- package/dist/find.mjs +3 -1
- package/dist/glob-to-regex.cjs +97 -1
- package/dist/glob-to-regex.mjs +97 -1
- package/dist/glob-to-regex.mjs.map +1 -1
- package/dist/index.cjs +73 -1
- package/dist/index.mjs +17 -1
- package/dist/is-parent-path.cjs +32 -1
- package/dist/is-parent-path.mjs +32 -1
- package/dist/is-parent-path.mjs.map +1 -1
- package/dist/is-root-dir.cjs +14 -1
- package/dist/is-root-dir.mjs +13 -1
- package/dist/is-root-dir.mjs.map +1 -1
- package/dist/is-type.cjs +92 -1
- package/dist/is-type.mjs +87 -1
- package/dist/is-type.mjs.map +1 -1
- package/dist/join-paths.cjs +108 -1
- package/dist/join-paths.mjs +107 -1
- package/dist/join-paths.mjs.map +1 -1
- package/dist/join.cjs +4 -1
- package/dist/join.mjs +3 -1
- package/dist/normalize.cjs +10 -1
- package/dist/normalize.mjs +3 -1
- package/dist/regex.cjs +20 -1
- package/dist/regex.mjs +12 -1
- package/dist/regex.mjs.map +1 -1
- package/dist/replace.cjs +44 -1
- package/dist/replace.mjs +43 -1
- package/dist/replace.mjs.map +1 -1
- package/dist/resolve-parent-path.cjs +18 -1
- package/dist/resolve-parent-path.mjs +18 -1
- package/dist/resolve-parent-path.mjs.map +1 -1
- package/dist/slash.cjs +27 -1
- package/dist/slash.mjs +26 -1
- package/dist/slash.mjs.map +1 -1
- package/dist/type-checks/src/is-empty.cjs +20 -1
- package/dist/type-checks/src/is-empty.mjs +20 -1
- package/dist/type-checks/src/is-empty.mjs.map +1 -1
- package/dist/type-checks/src/is-null.cjs +12 -1
- package/dist/type-checks/src/is-null.mjs +11 -1
- package/dist/type-checks/src/is-null.mjs.map +1 -1
- package/dist/type-checks/src/is-set-string.cjs +20 -1
- package/dist/type-checks/src/is-set-string.mjs +20 -1
- package/dist/type-checks/src/is-set-string.mjs.map +1 -1
- package/dist/type-checks/src/is-set.cjs +19 -1
- package/dist/type-checks/src/is-set.mjs +19 -1
- package/dist/type-checks/src/is-set.mjs.map +1 -1
- package/dist/type-checks/src/is-string.cjs +12 -1
- package/dist/type-checks/src/is-string.mjs +11 -1
- package/dist/type-checks/src/is-string.mjs.map +1 -1
- package/dist/type-checks/src/is-undefined.cjs +8 -1
- package/dist/type-checks/src/is-undefined.mjs +7 -1
- package/dist/type-checks/src/is-undefined.mjs.map +1 -1
- package/dist/types/src/base.cjs +6 -1
- package/dist/types/src/base.mjs +5 -1
- package/dist/types/src/base.mjs.map +1 -1
- package/package.json +5 -5
package/dist/correct-path.mjs
CHANGED
|
@@ -1,2 +1,170 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { cwd } from "./cwd.mjs";
|
|
2
|
+
import { DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, UNC_REGEX } from "./regex.mjs";
|
|
3
|
+
import { isAbsolutePath } from "./is-type.mjs";
|
|
4
|
+
import { slash } from "./slash.mjs";
|
|
5
|
+
import { joinPaths } from "./join-paths.mjs";
|
|
6
|
+
import { appendPath } from "./append.mjs";
|
|
7
|
+
|
|
8
|
+
//#region src/correct-path.ts
|
|
9
|
+
function normalizeWindowsPath(input = "") {
|
|
10
|
+
if (!input) return input;
|
|
11
|
+
return slash(input).replace(DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Corrects/normalized a file path.
|
|
15
|
+
*
|
|
16
|
+
* @param path - The path to correct.
|
|
17
|
+
* @returns The corrected path.
|
|
18
|
+
*/
|
|
19
|
+
function correctPath(path) {
|
|
20
|
+
if (!path || path.length === 0) return ".";
|
|
21
|
+
path = normalizeWindowsPath(path);
|
|
22
|
+
const isUNCPath = path.match(UNC_REGEX);
|
|
23
|
+
const isPathAbsolute = isAbsolutePath(path);
|
|
24
|
+
const trailingSeparator = path.endsWith("/");
|
|
25
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
26
|
+
if (path.length === 0) {
|
|
27
|
+
if (isPathAbsolute) return "/";
|
|
28
|
+
return trailingSeparator ? "./" : ".";
|
|
29
|
+
}
|
|
30
|
+
if (trailingSeparator) path += "/";
|
|
31
|
+
if (DRIVE_LETTER_REGEX.test(path)) path += "/";
|
|
32
|
+
if (isUNCPath) {
|
|
33
|
+
if (!isPathAbsolute) return `//./${path}`;
|
|
34
|
+
return `//${path}`;
|
|
35
|
+
}
|
|
36
|
+
return !path.startsWith("/") && isPathAbsolute && !DRIVE_LETTER_REGEX.test(path) ? `/${path}` : path;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Remove any star tokens (*) from the end of the file path
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* stripStars("src/**") // returns "src"
|
|
43
|
+
* stripStars("src/*") // returns "src"
|
|
44
|
+
* stripStars("src/**\/*") // returns "src"
|
|
45
|
+
* stripStars("src/**\/*.txt") // returns "src"
|
|
46
|
+
* stripStars("src/**\/file.txt") // returns "src"
|
|
47
|
+
* stripStars("src/file.txt") // returns "src/file.txt"
|
|
48
|
+
* stripStars("") // returns "."
|
|
49
|
+
*
|
|
50
|
+
* @param path - The path to correct.
|
|
51
|
+
* @returns The corrected path.
|
|
52
|
+
*/
|
|
53
|
+
function stripStars(path) {
|
|
54
|
+
if (!path || path.length === 0) return ".";
|
|
55
|
+
path = correctPath(path);
|
|
56
|
+
let found = false;
|
|
57
|
+
return `${path.startsWith("/") ? "/" : ""}${path.split("/").reduce((ret, segment) => {
|
|
58
|
+
if (!segment?.trim()) return ret;
|
|
59
|
+
if (found || segment.includes("*")) {
|
|
60
|
+
found = true;
|
|
61
|
+
return ret;
|
|
62
|
+
}
|
|
63
|
+
return ret + (ret ? `/${segment}` : segment);
|
|
64
|
+
}, "")}`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
|
68
|
+
*
|
|
69
|
+
* @param path - The path to normalize.
|
|
70
|
+
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
|
71
|
+
* @returns the normalize path string.
|
|
72
|
+
*/
|
|
73
|
+
function normalizeString(path, allowAboveRoot) {
|
|
74
|
+
let res = "";
|
|
75
|
+
let lastSegmentLength = 0;
|
|
76
|
+
let lastSlash = -1;
|
|
77
|
+
let dots = 0;
|
|
78
|
+
let char = null;
|
|
79
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
80
|
+
if (index < path.length) char = path[index];
|
|
81
|
+
else if (char === "/") break;
|
|
82
|
+
else char = "/";
|
|
83
|
+
if (char === "/") {
|
|
84
|
+
if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
|
|
85
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
86
|
+
if (res.length > 2) {
|
|
87
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
88
|
+
if (lastSlashIndex === -1) {
|
|
89
|
+
res = "";
|
|
90
|
+
lastSegmentLength = 0;
|
|
91
|
+
} else {
|
|
92
|
+
res = res.slice(0, lastSlashIndex);
|
|
93
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
94
|
+
}
|
|
95
|
+
lastSlash = index;
|
|
96
|
+
dots = 0;
|
|
97
|
+
continue;
|
|
98
|
+
} else if (res.length > 0) {
|
|
99
|
+
res = "";
|
|
100
|
+
lastSegmentLength = 0;
|
|
101
|
+
lastSlash = index;
|
|
102
|
+
dots = 0;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (allowAboveRoot) {
|
|
107
|
+
res += res.length > 0 ? "/.." : "..";
|
|
108
|
+
lastSegmentLength = 2;
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
112
|
+
else res = path.slice(lastSlash + 1, index);
|
|
113
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
114
|
+
}
|
|
115
|
+
lastSlash = index;
|
|
116
|
+
dots = 0;
|
|
117
|
+
} else if (char === "." && dots !== -1) ++dots;
|
|
118
|
+
else dots = -1;
|
|
119
|
+
}
|
|
120
|
+
return res;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Converts a given path to an absolute path based on the current working directory.
|
|
124
|
+
*
|
|
125
|
+
* @param path - The path to convert to an absolute path.
|
|
126
|
+
* @param cwd - The current working directory to use as the base path if the path is not absolute.
|
|
127
|
+
* @returns The absolute path.
|
|
128
|
+
*/
|
|
129
|
+
function toAbsolutePath(path, cwd$1 = cwd()) {
|
|
130
|
+
if (isAbsolutePath(path)) return path;
|
|
131
|
+
return slash(normalizeString(appendPath(path, cwd$1), true));
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Converts a given path to a relative path based on the current working directory.
|
|
135
|
+
*
|
|
136
|
+
* @param path - The path to convert to a relative path.
|
|
137
|
+
* @param cwd - The current working directory to use as the base path if the path is not absolute.
|
|
138
|
+
* @returns The relative path.
|
|
139
|
+
*/
|
|
140
|
+
function toRelativePath(path, cwd$1 = cwd()) {
|
|
141
|
+
if (!path || path.length === 0) return ".";
|
|
142
|
+
if (isAbsolutePath(path)) path = slash(normalizeString(path, true));
|
|
143
|
+
else path = slash(normalizeString(joinPaths(cwd$1, path), true));
|
|
144
|
+
if (path.startsWith("./")) return path.slice(2);
|
|
145
|
+
return path;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Adds a trailing slash to a path if it doesn't already have one.
|
|
149
|
+
*
|
|
150
|
+
* @param path - The path to modify.
|
|
151
|
+
* @returns The modified path with a trailing slash.
|
|
152
|
+
*/
|
|
153
|
+
function withTrailingSlash(path) {
|
|
154
|
+
const result = correctPath(path);
|
|
155
|
+
return result.endsWith("/") ? result : `${result}/`;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Removes a trailing slash from a path if it has one.
|
|
159
|
+
*
|
|
160
|
+
* @param path - The path to modify.
|
|
161
|
+
* @returns The modified path without a trailing slash.
|
|
162
|
+
*/
|
|
163
|
+
function withoutTrailingSlash(path) {
|
|
164
|
+
const result = correctPath(path);
|
|
165
|
+
return result.endsWith("/") ? result.slice(0, -1) : result;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
//#endregion
|
|
169
|
+
export { correctPath, normalizeString, normalizeWindowsPath, stripStars, toAbsolutePath, toRelativePath, withTrailingSlash, withoutTrailingSlash };
|
|
2
170
|
//# sourceMappingURL=correct-path.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"correct-path.mjs","names":["char: string | null","currentDir","cwd"],"sources":["../src/correct-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 { appendPath } from \"./append\";\nimport { cwd as currentDir } from \"./cwd\";\nimport { isAbsolutePath } from \"./is-type\";\nimport { joinPaths } from \"./join-paths\";\nimport {\n DRIVE_LETTER_REGEX,\n DRIVE_LETTER_START_REGEX,\n UNC_REGEX\n} from \"./regex\";\nimport { slash } from \"./slash\";\n\n// Util to normalize windows paths to posix\nexport function normalizeWindowsPath(input = \"\") {\n if (!input) {\n return input;\n }\n\n return slash(input).replace(DRIVE_LETTER_START_REGEX, r => r.toUpperCase());\n}\n\n/**\n * Corrects/normalized a file path.\n *\n * @param path - The path to correct.\n * @returns The corrected path.\n */\nexport function correctPath(path?: string) {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n // Normalize windows argument\n path = normalizeWindowsPath(path);\n\n const isUNCPath = path.match(UNC_REGEX);\n const isPathAbsolute = isAbsolutePath(path);\n const trailingSeparator = path.endsWith(\"/\");\n\n // Normalize the path\n path = normalizeString(path, !isPathAbsolute);\n\n if (path.length === 0) {\n if (isPathAbsolute) {\n return \"/\";\n }\n return trailingSeparator ? \"./\" : \".\";\n }\n\n if (trailingSeparator) {\n path += \"/\";\n }\n if (DRIVE_LETTER_REGEX.test(path)) {\n path += \"/\";\n }\n\n if (isUNCPath) {\n if (!isPathAbsolute) {\n return `//./${path}`;\n }\n return `//${path}`;\n }\n\n return !path.startsWith(\"/\") &&\n isPathAbsolute &&\n !DRIVE_LETTER_REGEX.test(path)\n ? `/${path}`\n : path;\n}\n\n/**\n * Remove any star tokens (*) from the end of the file path\n *\n * @example\n * stripStars(\"src/**\") // returns \"src\"\n * stripStars(\"src/*\") // returns \"src\"\n * stripStars(\"src/**\\/*\") // returns \"src\"\n * stripStars(\"src/**\\/*.txt\") // returns \"src\"\n * stripStars(\"src/**\\/file.txt\") // returns \"src\"\n * stripStars(\"src/file.txt\") // returns \"src/file.txt\"\n * stripStars(\"\") // returns \".\"\n *\n * @param path - The path to correct.\n * @returns The corrected path.\n */\nexport function stripStars(path?: string) {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n path = correctPath(path);\n\n let found = false;\n\n return `${path.startsWith(\"/\") ? \"/\" : \"\"}${path\n .split(\"/\")\n .reduce((ret, segment) => {\n if (!segment?.trim()) {\n return ret;\n }\n\n if (found || segment.includes(\"*\")) {\n found = true;\n return ret;\n }\n\n return ret + (ret ? `/${segment}` : segment);\n }, \"\")}`;\n}\n\n/**\n * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.\n *\n * @param path - The path to normalize.\n * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.\n * @returns the normalize path string.\n */\nexport function normalizeString(path: string, allowAboveRoot: boolean) {\n let res = \"\";\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let char: string | null = null;\n for (let index = 0; index <= path.length; ++index) {\n if (index < path.length) {\n // casted because we know it exists thanks to the length check\n char = path[index] as string;\n } else if (char === \"/\") {\n break;\n } else {\n char = \"/\";\n }\n if (char === \"/\") {\n if (lastSlash === index - 1 || dots === 1) {\n // NOOP\n } else if (dots === 2) {\n if (\n res.length < 2 ||\n lastSegmentLength !== 2 ||\n res[res.length - 1] !== \".\" ||\n res[res.length - 2] !== \".\"\n ) {\n if (res.length > 2) {\n const lastSlashIndex = res.lastIndexOf(\"/\");\n if (lastSlashIndex === -1) {\n res = \"\";\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf(\"/\");\n }\n lastSlash = index;\n dots = 0;\n continue;\n } else if (res.length > 0) {\n res = \"\";\n lastSegmentLength = 0;\n lastSlash = index;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n res += res.length > 0 ? \"/..\" : \"..\";\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0) {\n res += `/${path.slice(lastSlash + 1, index)}`;\n } else {\n res = path.slice(lastSlash + 1, index);\n }\n lastSegmentLength = index - lastSlash - 1;\n }\n lastSlash = index;\n dots = 0;\n } else if (char === \".\" && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n\n/**\n * Converts a given path to an absolute path based on the current working directory.\n *\n * @param path - The path to convert to an absolute path.\n * @param cwd - The current working directory to use as the base path if the path is not absolute.\n * @returns The absolute path.\n */\nexport function toAbsolutePath(path: string, cwd = currentDir()): string {\n if (isAbsolutePath(path)) {\n return path;\n }\n\n return slash(normalizeString(appendPath(path, cwd), true));\n}\n\n/**\n * Converts a given path to a relative path based on the current working directory.\n *\n * @param path - The path to convert to a relative path.\n * @param cwd - The current working directory to use as the base path if the path is not absolute.\n * @returns The relative path.\n */\nexport function toRelativePath(path: string, cwd = currentDir()): string {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n if (isAbsolutePath(path)) {\n path = slash(normalizeString(path, true));\n } else {\n path = slash(normalizeString(joinPaths(cwd, path), true));\n }\n\n if (path.startsWith(\"./\")) {\n return path.slice(2);\n }\n\n return path;\n}\n\n/**\n * Adds a trailing slash to a path if it doesn't already have one.\n *\n * @param path - The path to modify.\n * @returns The modified path with a trailing slash.\n */\nexport function withTrailingSlash(path: string): string {\n const result = correctPath(path);\n\n return result.endsWith(\"/\") ? result : `${result}/`;\n}\n\n/**\n * Removes a trailing slash from a path if it has one.\n *\n * @param path - The path to modify.\n * @returns The modified path without a trailing slash.\n */\nexport function withoutTrailingSlash(path: string): string {\n const result = correctPath(path);\n\n return result.endsWith(\"/\") ? result.slice(0, -1) : result;\n}\n"],"mappings":"wSA8BA,SAAgB,EAAqB,EAAQ,GAAI,CAK/C,OAJK,GAIE,EAAM,EAAM,CAAC,QAAQ,EAA0B,GAAK,EAAE,aAAa,CAAC,CAS7E,SAAgB,EAAY,EAAe,CACzC,GAAI,CAAC,GAAQ,EAAK,SAAW,EAC3B,MAAO,IAIT,EAAO,EAAqB,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,EAAI,MAAM,EAAG,EAAe,CAClC,EAAoB,EAAI,OAAS,EAAI,EAAI,YAAY,IAAI,EAE3D,EAAY,EACZ,EAAO,EACP,iBACS,EAAI,OAAS,EAAG,CACzB,EAAM,GACN,EAAoB,EACpB,EAAY,EACZ,EAAO,EACP,UAGA,IACF,GAAO,EAAI,OAAS,EAAI,MAAQ,KAChC,EAAoB,QAGlB,EAAI,OAAS,EACf,GAAO,IAAI,EAAK,MAAM,EAAY,EAAG,EAAM,GAE3C,EAAM,EAAK,MAAM,EAAY,EAAG,EAAM,CAExC,EAAoB,EAAQ,EAAY,EAE1C,EAAY,EACZ,EAAO,OACE,IAAS,KAAO,IAAS,GAClC,EAAE,EAEF,EAAO,GAGX,OAAO,EAUT,SAAgB,EAAe,EAAc,EAAMC,GAAY,CAAU,CAKvE,OAJI,EAAe,EAAK,CACf,EAGF,EAAM,EAAgB,EAAW,EAAMC,EAAI,CAAE,GAAK,CAAC,CAU5D,SAAgB,EAAe,EAAc,EAAMD,GAAY,CAAU,CAevE,MAdI,CAAC,GAAQ,EAAK,SAAW,EACpB,KAGT,AAGE,EAHE,EAAe,EAAK,CACf,EAAM,EAAgB,EAAM,GAAK,CAAC,CAElC,EAAM,EAAgB,EAAUC,EAAK,EAAK,CAAE,GAAK,CAAC,CAGvD,EAAK,WAAW,KAAK,CAChB,EAAK,MAAM,EAAE,CAGf,GAST,SAAgB,EAAkB,EAAsB,CACtD,IAAM,EAAS,EAAY,EAAK,CAEhC,OAAO,EAAO,SAAS,IAAI,CAAG,EAAS,GAAG,EAAO,GASnD,SAAgB,EAAqB,EAAsB,CACzD,IAAM,EAAS,EAAY,EAAK,CAEhC,OAAO,EAAO,SAAS,IAAI,CAAG,EAAO,MAAM,EAAG,GAAG,CAAG"}
|
|
1
|
+
{"version":3,"file":"correct-path.mjs","names":["char: string | null","currentDir","cwd"],"sources":["../src/correct-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 { appendPath } from \"./append\";\nimport { cwd as currentDir } from \"./cwd\";\nimport { isAbsolutePath } from \"./is-type\";\nimport { joinPaths } from \"./join-paths\";\nimport {\n DRIVE_LETTER_REGEX,\n DRIVE_LETTER_START_REGEX,\n UNC_REGEX\n} from \"./regex\";\nimport { slash } from \"./slash\";\n\n// Util to normalize windows paths to posix\nexport function normalizeWindowsPath(input = \"\") {\n if (!input) {\n return input;\n }\n\n return slash(input).replace(DRIVE_LETTER_START_REGEX, r => r.toUpperCase());\n}\n\n/**\n * Corrects/normalized a file path.\n *\n * @param path - The path to correct.\n * @returns The corrected path.\n */\nexport function correctPath(path?: string) {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n // Normalize windows argument\n path = normalizeWindowsPath(path);\n\n const isUNCPath = path.match(UNC_REGEX);\n const isPathAbsolute = isAbsolutePath(path);\n const trailingSeparator = path.endsWith(\"/\");\n\n // Normalize the path\n path = normalizeString(path, !isPathAbsolute);\n\n if (path.length === 0) {\n if (isPathAbsolute) {\n return \"/\";\n }\n return trailingSeparator ? \"./\" : \".\";\n }\n\n if (trailingSeparator) {\n path += \"/\";\n }\n if (DRIVE_LETTER_REGEX.test(path)) {\n path += \"/\";\n }\n\n if (isUNCPath) {\n if (!isPathAbsolute) {\n return `//./${path}`;\n }\n return `//${path}`;\n }\n\n return !path.startsWith(\"/\") &&\n isPathAbsolute &&\n !DRIVE_LETTER_REGEX.test(path)\n ? `/${path}`\n : path;\n}\n\n/**\n * Remove any star tokens (*) from the end of the file path\n *\n * @example\n * stripStars(\"src/**\") // returns \"src\"\n * stripStars(\"src/*\") // returns \"src\"\n * stripStars(\"src/**\\/*\") // returns \"src\"\n * stripStars(\"src/**\\/*.txt\") // returns \"src\"\n * stripStars(\"src/**\\/file.txt\") // returns \"src\"\n * stripStars(\"src/file.txt\") // returns \"src/file.txt\"\n * stripStars(\"\") // returns \".\"\n *\n * @param path - The path to correct.\n * @returns The corrected path.\n */\nexport function stripStars(path?: string) {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n path = correctPath(path);\n\n let found = false;\n\n return `${path.startsWith(\"/\") ? \"/\" : \"\"}${path\n .split(\"/\")\n .reduce((ret, segment) => {\n if (!segment?.trim()) {\n return ret;\n }\n\n if (found || segment.includes(\"*\")) {\n found = true;\n return ret;\n }\n\n return ret + (ret ? `/${segment}` : segment);\n }, \"\")}`;\n}\n\n/**\n * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.\n *\n * @param path - The path to normalize.\n * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.\n * @returns the normalize path string.\n */\nexport function normalizeString(path: string, allowAboveRoot: boolean) {\n let res = \"\";\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let char: string | null = null;\n for (let index = 0; index <= path.length; ++index) {\n if (index < path.length) {\n // casted because we know it exists thanks to the length check\n char = path[index] as string;\n } else if (char === \"/\") {\n break;\n } else {\n char = \"/\";\n }\n if (char === \"/\") {\n if (lastSlash === index - 1 || dots === 1) {\n // NOOP\n } else if (dots === 2) {\n if (\n res.length < 2 ||\n lastSegmentLength !== 2 ||\n res[res.length - 1] !== \".\" ||\n res[res.length - 2] !== \".\"\n ) {\n if (res.length > 2) {\n const lastSlashIndex = res.lastIndexOf(\"/\");\n if (lastSlashIndex === -1) {\n res = \"\";\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf(\"/\");\n }\n lastSlash = index;\n dots = 0;\n continue;\n } else if (res.length > 0) {\n res = \"\";\n lastSegmentLength = 0;\n lastSlash = index;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n res += res.length > 0 ? \"/..\" : \"..\";\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0) {\n res += `/${path.slice(lastSlash + 1, index)}`;\n } else {\n res = path.slice(lastSlash + 1, index);\n }\n lastSegmentLength = index - lastSlash - 1;\n }\n lastSlash = index;\n dots = 0;\n } else if (char === \".\" && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n\n/**\n * Converts a given path to an absolute path based on the current working directory.\n *\n * @param path - The path to convert to an absolute path.\n * @param cwd - The current working directory to use as the base path if the path is not absolute.\n * @returns The absolute path.\n */\nexport function toAbsolutePath(path: string, cwd = currentDir()): string {\n if (isAbsolutePath(path)) {\n return path;\n }\n\n return slash(normalizeString(appendPath(path, cwd), true));\n}\n\n/**\n * Converts a given path to a relative path based on the current working directory.\n *\n * @param path - The path to convert to a relative path.\n * @param cwd - The current working directory to use as the base path if the path is not absolute.\n * @returns The relative path.\n */\nexport function toRelativePath(path: string, cwd = currentDir()): string {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n if (isAbsolutePath(path)) {\n path = slash(normalizeString(path, true));\n } else {\n path = slash(normalizeString(joinPaths(cwd, path), true));\n }\n\n if (path.startsWith(\"./\")) {\n return path.slice(2);\n }\n\n return path;\n}\n\n/**\n * Adds a trailing slash to a path if it doesn't already have one.\n *\n * @param path - The path to modify.\n * @returns The modified path with a trailing slash.\n */\nexport function withTrailingSlash(path: string): string {\n const result = correctPath(path);\n\n return result.endsWith(\"/\") ? result : `${result}/`;\n}\n\n/**\n * Removes a trailing slash from a path if it has one.\n *\n * @param path - The path to modify.\n * @returns The modified path without a trailing slash.\n */\nexport function withoutTrailingSlash(path: string): string {\n const result = correctPath(path);\n\n return result.endsWith(\"/\") ? result.slice(0, -1) : result;\n}\n"],"mappings":";;;;;;;;AA8BA,SAAgB,qBAAqB,QAAQ,IAAI;AAC/C,KAAI,CAAC,MACH,Q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K,CAAC;KAEzC,QAAO,MAAM,gBAAgB,UAAUC,OAAK,KAAK,EAAE,KAAK,CAAC;AAG3D,KAAI,KAAK,WAAW,KAAK,CACvB,QAAO,KAAK,MAAM,EAAE;AAGtB,QAAO;;;;;;;;AAST,SAAgB,kBAAkB,MAAsB;CACtD,MAAM,SAAS,YAAY,KAAK;AAEhC,QAAO,OAAO,SAAS,IAAI,GAAG,SAAS,GAAG,OAAO;;;;;;;;AASnD,SAAgB,qBAAqB,MAAsB;CACzD,MAAM,SAAS,YAAY,KAAK;AAEhC,QAAO,OAAO,SAAS,IAAI,GAAG,OAAO,MAAM,GAAG,GAAG,GAAG"}
|
package/dist/cwd.cjs
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/cwd.ts
|
|
3
|
+
/**
|
|
4
|
+
* Get the current working directory.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This function attempts to retrieve the current working directory using `process.cwd()`.
|
|
8
|
+
*
|
|
9
|
+
* @returns The current working directory or '/' if it cannot be determined
|
|
10
|
+
*/
|
|
11
|
+
function cwd() {
|
|
12
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
13
|
+
return "/";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.cwd = cwd;
|
package/dist/cwd.mjs
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/cwd.ts
|
|
2
|
+
/**
|
|
3
|
+
* Get the current working directory.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This function attempts to retrieve the current working directory using `process.cwd()`.
|
|
7
|
+
*
|
|
8
|
+
* @returns The current working directory or '/' if it cannot be determined
|
|
9
|
+
*/
|
|
10
|
+
function cwd() {
|
|
11
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
12
|
+
return "/";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { cwd };
|
|
2
17
|
//# sourceMappingURL=cwd.mjs.map
|
package/dist/cwd.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cwd.mjs","names":[],"sources":["../src/cwd.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 * Get the current working directory.\n *\n * @remarks\n * This function attempts to retrieve the current working directory using `process.cwd()`.\n *\n * @returns The current working directory or '/' if it cannot be determined\n */\nexport function cwd() {\n if (typeof process !== \"undefined\" && typeof process.cwd === \"function\") {\n return process.cwd().replace(/\\\\/g, \"/\");\n }\n return \"/\";\n}\n"],"mappings":"AA0BA,SAAgB,
|
|
1
|
+
{"version":3,"file":"cwd.mjs","names":[],"sources":["../src/cwd.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 * Get the current working directory.\n *\n * @remarks\n * This function attempts to retrieve the current working directory using `process.cwd()`.\n *\n * @returns The current working directory or '/' if it cannot be determined\n */\nexport function cwd() {\n if (typeof process !== \"undefined\" && typeof process.cwd === \"function\") {\n return process.cwd().replace(/\\\\/g, \"/\");\n }\n return \"/\";\n}\n"],"mappings":";;;;;;;;;AA0BA,SAAgB,MAAM;AACpB,KAAI,OAAO,YAAY,eAAe,OAAO,QAAQ,QAAQ,WAC3D,QAAO,QAAQ,KAAK,CAAC,QAAQ,OAAO,IAAI;AAE1C,QAAO"}
|
package/dist/delimiter.cjs
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/delimiter.ts
|
|
3
|
+
/**
|
|
4
|
+
* The platform-specific file delimiter.
|
|
5
|
+
*
|
|
6
|
+
* Equals to `";"` in windows and `":"` in all other platforms.
|
|
7
|
+
*/
|
|
8
|
+
const delimiter = /* @__PURE__ */ (() => process?.platform === "win32" ? ";" : ":")();
|
|
9
|
+
const platforms = {
|
|
10
|
+
posix: void 0,
|
|
11
|
+
win32: void 0
|
|
12
|
+
};
|
|
13
|
+
const mix = (del = delimiter) => {
|
|
14
|
+
return new Proxy({}, { get(_, prop) {
|
|
15
|
+
if (prop === "delimiter") return del;
|
|
16
|
+
if (prop === "posix") return posix;
|
|
17
|
+
if (prop === "win32") return win32;
|
|
18
|
+
return platforms[prop];
|
|
19
|
+
} });
|
|
20
|
+
};
|
|
21
|
+
const posix = /* @__PURE__ */ mix(":");
|
|
22
|
+
const win32 = /* @__PURE__ */ mix(";");
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.delimiter = delimiter;
|
|
26
|
+
exports.posix = posix;
|
|
27
|
+
exports.win32 = win32;
|
package/dist/delimiter.mjs
CHANGED
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/delimiter.ts
|
|
2
|
+
/**
|
|
3
|
+
* The platform-specific file delimiter.
|
|
4
|
+
*
|
|
5
|
+
* Equals to `";"` in windows and `":"` in all other platforms.
|
|
6
|
+
*/
|
|
7
|
+
const delimiter = /* @__PURE__ */ (() => process?.platform === "win32" ? ";" : ":")();
|
|
8
|
+
const platforms = {
|
|
9
|
+
posix: void 0,
|
|
10
|
+
win32: void 0
|
|
11
|
+
};
|
|
12
|
+
const mix = (del = delimiter) => {
|
|
13
|
+
return new Proxy({}, { get(_, prop) {
|
|
14
|
+
if (prop === "delimiter") return del;
|
|
15
|
+
if (prop === "posix") return posix;
|
|
16
|
+
if (prop === "win32") return win32;
|
|
17
|
+
return platforms[prop];
|
|
18
|
+
} });
|
|
19
|
+
};
|
|
20
|
+
const posix = /* @__PURE__ */ mix(":");
|
|
21
|
+
const win32 = /* @__PURE__ */ mix(";");
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { delimiter, posix, win32 };
|
|
2
25
|
//# sourceMappingURL=delimiter.mjs.map
|
package/dist/delimiter.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delimiter.mjs","names":["delimiter: \";\" | \":\""],"sources":["../src/delimiter.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 * The platform-specific file delimiter.\n *\n * Equals to `\";\"` in windows and `\":\"` in all other platforms.\n */\nexport const delimiter: \";\" | \":\" = /* @__PURE__ */ (() =>\n process?.platform === \"win32\" ? \";\" : \":\")();\n\n// Mix namespaces without side-effects of object to allow tree-shaking\n\nconst platforms = {\n posix: undefined,\n win32: undefined\n} as unknown as {\n posix: any;\n win32: any;\n};\n\nconst mix = (del: \";\" | \":\" = delimiter) => {\n return new Proxy(\n {},\n {\n get(_, prop) {\n if (prop === \"delimiter\") {\n return del;\n }\n if (prop === \"posix\") {\n // eslint-disable-next-line ts/no-use-before-define\n return posix;\n }\n if (prop === \"win32\") {\n // eslint-disable-next-line ts/no-use-before-define\n return win32;\n }\n return platforms[prop as keyof typeof platforms];\n }\n }\n ) as unknown as typeof platforms & { delimiter: typeof del };\n};\n\nexport const posix = /* @__PURE__ */ mix(\":\");\n\nexport const win32 = /* @__PURE__ */ mix(\";\");\n"],"mappings":"AAuBA,MAAaA,
|
|
1
|
+
{"version":3,"file":"delimiter.mjs","names":["delimiter: \";\" | \":\""],"sources":["../src/delimiter.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 * The platform-specific file delimiter.\n *\n * Equals to `\";\"` in windows and `\":\"` in all other platforms.\n */\nexport const delimiter: \";\" | \":\" = /* @__PURE__ */ (() =>\n process?.platform === \"win32\" ? \";\" : \":\")();\n\n// Mix namespaces without side-effects of object to allow tree-shaking\n\nconst platforms = {\n posix: undefined,\n win32: undefined\n} as unknown as {\n posix: any;\n win32: any;\n};\n\nconst mix = (del: \";\" | \":\" = delimiter) => {\n return new Proxy(\n {},\n {\n get(_, prop) {\n if (prop === \"delimiter\") {\n return del;\n }\n if (prop === \"posix\") {\n // eslint-disable-next-line ts/no-use-before-define\n return posix;\n }\n if (prop === \"win32\") {\n // eslint-disable-next-line ts/no-use-before-define\n return win32;\n }\n return platforms[prop as keyof typeof platforms];\n }\n }\n ) as unknown as typeof platforms & { delimiter: typeof del };\n};\n\nexport const posix = /* @__PURE__ */ mix(\":\");\n\nexport const win32 = /* @__PURE__ */ mix(\";\");\n"],"mappings":";;;;;;AAuBA,MAAaA,YAAuC,uBAClD,SAAS,aAAa,UAAU,MAAM,MAAM;AAI9C,MAAM,YAAY;CAChB,OAAO;CACP,OAAO;CACR;AAKD,MAAM,OAAO,MAAiB,cAAc;AAC1C,QAAO,IAAI,MACT,EAAE,EACF,EACE,IAAI,GAAG,MAAM;AACX,MAAI,SAAS,YACX,QAAO;AAET,MAAI,SAAS,QAEX,QAAO;AAET,MAAI,SAAS,QAEX,QAAO;AAET,SAAO,UAAU;IAEpB,CACF;;AAGH,MAAa,QAAwB,oBAAI,IAAI;AAE7C,MAAa,QAAwB,oBAAI,IAAI"}
|