@stryke/path 0.4.7 â 0.4.9
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 +2 -1
- package/dist/file-path-fns.cjs +38 -38
- package/dist/file-path-fns.mjs +1 -1
- package/package.json +3 -7
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
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
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
|
|
@@ -51,6 +51,7 @@ built-in \`path\` module
|
|
|
51
51
|
|
|
52
52
|
<!-- START doctoc -->
|
|
53
53
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
54
|
+
|
|
54
55
|
## Table of Contents
|
|
55
56
|
|
|
56
57
|
- [Installing](#installing)
|
package/dist/file-path-fns.cjs
CHANGED
|
@@ -20,24 +20,24 @@ var _correctPath = require("./correct-path.cjs");
|
|
|
20
20
|
var _getWorkspaceRoot = require("./get-workspace-root.cjs");
|
|
21
21
|
var _isFile = require("./is-file.cjs");
|
|
22
22
|
var _joinPaths = require("./join-paths.cjs");
|
|
23
|
-
function findFileName(
|
|
24
|
-
requireExtension:
|
|
23
|
+
function findFileName(e, {
|
|
24
|
+
requireExtension: n,
|
|
25
25
|
withExtension: r
|
|
26
26
|
} = {}) {
|
|
27
|
-
const t = (0, _correctPath.normalizeWindowsPath)(
|
|
28
|
-
return
|
|
27
|
+
const t = (0, _correctPath.normalizeWindowsPath)(e)?.split(e?.includes("\\") ? "\\" : "/")?.pop() ?? "";
|
|
28
|
+
return n === !0 && !t.includes(".") ? _base.EMPTY_STRING : r === !1 && t.includes(".") ? t.split(".").slice(-1).join(".") || _base.EMPTY_STRING : t;
|
|
29
29
|
}
|
|
30
|
-
function findFilePath(
|
|
31
|
-
const
|
|
32
|
-
return
|
|
30
|
+
function findFilePath(e) {
|
|
31
|
+
const n = (0, _correctPath.normalizeWindowsPath)(e);
|
|
32
|
+
return n.replace(findFileName(n, {
|
|
33
33
|
requireExtension: !0
|
|
34
34
|
}), "");
|
|
35
35
|
}
|
|
36
|
-
function findFolderName(
|
|
37
|
-
const
|
|
36
|
+
function findFolderName(e) {
|
|
37
|
+
const n = findFilePath(e).split("/");
|
|
38
38
|
let r = "";
|
|
39
|
-
for (let t =
|
|
40
|
-
const i =
|
|
39
|
+
for (let t = n.length - 1; t >= 0; t--) {
|
|
40
|
+
const i = n[t];
|
|
41
41
|
if (i) {
|
|
42
42
|
r = i;
|
|
43
43
|
break;
|
|
@@ -45,33 +45,33 @@ function findFolderName(n) {
|
|
|
45
45
|
}
|
|
46
46
|
return r ?? _base.EMPTY_STRING;
|
|
47
47
|
}
|
|
48
|
-
function findFileExtension(
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
51
|
-
return
|
|
48
|
+
function findFileExtension(e) {
|
|
49
|
+
if (e === "..") return "";
|
|
50
|
+
const n = /.(\.[^./]+|\.)$/.exec((0, _correctPath.normalizeWindowsPath)(e));
|
|
51
|
+
return n && n[1] || _base.EMPTY_STRING;
|
|
52
52
|
}
|
|
53
|
-
function hasFileName(
|
|
54
|
-
return !!findFileName(
|
|
53
|
+
function hasFileName(e) {
|
|
54
|
+
return !!findFileName(e);
|
|
55
55
|
}
|
|
56
|
-
function hasFilePath(
|
|
57
|
-
return !!findFilePath(
|
|
56
|
+
function hasFilePath(e) {
|
|
57
|
+
return !!findFilePath(e);
|
|
58
58
|
}
|
|
59
|
-
function resolvePath(
|
|
60
|
-
const r = (0, _correctPath.normalizeWindowsPath)(
|
|
59
|
+
function resolvePath(e, n = (0, _getWorkspaceRoot.getWorkspaceRoot)()) {
|
|
60
|
+
const r = (0, _correctPath.normalizeWindowsPath)(e).split("/");
|
|
61
61
|
let t = "",
|
|
62
62
|
i = !1;
|
|
63
63
|
for (let o = r.length - 1; o >= -1 && !i; o--) {
|
|
64
|
-
const s = o >= 0 ? r[o] :
|
|
64
|
+
const s = o >= 0 ? r[o] : n;
|
|
65
65
|
!s || s.length === 0 || (t = (0, _joinPaths.joinPaths)(s, t), i = (0, _isFile.isAbsolutePath)(s));
|
|
66
66
|
}
|
|
67
67
|
return t = (0, _correctPath.normalizeString)(t, !i), i && !(0, _isFile.isAbsolutePath)(t) ? `/${t}` : t.length > 0 ? t : ".";
|
|
68
68
|
}
|
|
69
|
-
function resolvePaths(...
|
|
70
|
-
return resolvePath((0, _joinPaths.joinPaths)(...
|
|
69
|
+
function resolvePaths(...e) {
|
|
70
|
+
return resolvePath((0, _joinPaths.joinPaths)(...e.map(n => (0, _correctPath.normalizeWindowsPath)(n))));
|
|
71
71
|
}
|
|
72
|
-
function relativePath(
|
|
73
|
-
const r = resolvePath(
|
|
74
|
-
t = resolvePath(
|
|
72
|
+
function relativePath(e, n) {
|
|
73
|
+
const r = resolvePath(e.replace(/\/$/, "")).replace(/^\/([A-Z]:)?$/i, "$1").split("/"),
|
|
74
|
+
t = resolvePath(n.replace(/\/$/, "")).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
|
|
75
75
|
if (t[0][1] === ":" && r[0][1] === ":" && r[0] !== t[0]) return t.join("/");
|
|
76
76
|
const i = [...r];
|
|
77
77
|
for (const o of i) {
|
|
@@ -80,26 +80,26 @@ function relativePath(n, e) {
|
|
|
80
80
|
}
|
|
81
81
|
return [...r.map(() => ".."), ...t].join("/");
|
|
82
82
|
}
|
|
83
|
-
function relativeToWorkspaceRoot(
|
|
84
|
-
return relativePath(
|
|
83
|
+
function relativeToWorkspaceRoot(e) {
|
|
84
|
+
return relativePath(e, (0, _getWorkspaceRoot.getWorkspaceRoot)());
|
|
85
85
|
}
|
|
86
|
-
function parsePath(
|
|
87
|
-
const
|
|
88
|
-
r = (0, _correctPath.normalizeWindowsPath)(
|
|
86
|
+
function parsePath(e) {
|
|
87
|
+
const n = /^[/\\]|^[a-z]:[/\\]/i.exec(e)?.[0]?.replace(/\\/g, "/") || "",
|
|
88
|
+
r = (0, _correctPath.normalizeWindowsPath)(e),
|
|
89
89
|
t = r.replace(/\/$/, "").split("/").slice(0, -1);
|
|
90
90
|
t.length === 1 && /^[A-Z]:$/i.test(t[0]) && (t[0] += "/");
|
|
91
91
|
const i = findFolderName(r),
|
|
92
|
-
o = t.join("/") || ((0, _isFile.isAbsolutePath)(
|
|
93
|
-
s = findFileExtension(
|
|
92
|
+
o = t.join("/") || ((0, _isFile.isAbsolutePath)(e) ? "/" : "."),
|
|
93
|
+
s = findFileExtension(e);
|
|
94
94
|
return {
|
|
95
|
-
root:
|
|
95
|
+
root: n,
|
|
96
96
|
dir: o,
|
|
97
97
|
base: i,
|
|
98
98
|
ext: s,
|
|
99
99
|
name: i.slice(0, i.length - s.length)
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
function renameFile(
|
|
103
|
-
const r = parsePath(
|
|
104
|
-
return (0, _joinPaths.joinPaths)(r.dir,
|
|
102
|
+
function renameFile(e, n) {
|
|
103
|
+
const r = parsePath(e);
|
|
104
|
+
return (0, _joinPaths.joinPaths)(r.dir, n.includes(".") ? n : n + r.ext);
|
|
105
105
|
}
|
package/dist/file-path-fns.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EMPTY_STRING as a}from"@stryke/types/base";import{normalizeString as
|
|
1
|
+
import{EMPTY_STRING as a}from"@stryke/types/base";import{normalizeString as f,normalizeWindowsPath as l}from"./correct-path";import{getWorkspaceRoot as u}from"./get-workspace-root";import{isAbsolutePath as c}from"./is-file";import{joinPaths as p}from"./join-paths";export function findFileName(e,{requireExtension:n,withExtension:r}={}){const t=l(e)?.split(e?.includes("\\")?"\\":"/")?.pop()??"";return n===!0&&!t.includes(".")?a:r===!1&&t.includes(".")?t.split(".").slice(-1).join(".")||a:t}export function findFilePath(e){const n=l(e);return n.replace(findFileName(n,{requireExtension:!0}),"")}export function findFolderName(e){const n=findFilePath(e).split("/");let r="";for(let t=n.length-1;t>=0;t--){const i=n[t];if(i){r=i;break}}return r??a}export function findFileExtension(e){if(e==="..")return"";const n=/.(\.[^./]+|\.)$/.exec(l(e));return n&&n[1]||a}export function hasFileName(e){return!!findFileName(e)}export function hasFilePath(e){return!!findFilePath(e)}export function resolvePath(e,n=u()){const r=l(e).split("/");let t="",i=!1;for(let o=r.length-1;o>=-1&&!i;o--){const s=o>=0?r[o]:n;!s||s.length===0||(t=p(s,t),i=c(s))}return t=f(t,!i),i&&!c(t)?`/${t}`:t.length>0?t:"."}export function resolvePaths(...e){return resolvePath(p(...e.map(n=>l(n))))}export function relativePath(e,n){const r=resolvePath(e.replace(/\/$/,"")).replace(/^\/([A-Z]:)?$/i,"$1").split("/"),t=resolvePath(n.replace(/\/$/,"")).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(e){return relativePath(e,u())}export function parsePath(e){const n=/^[/\\]|^[a-z]:[/\\]/i.exec(e)?.[0]?.replace(/\\/g,"/")||"",r=l(e),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(e)?"/":"."),s=findFileExtension(e);return{root:n,dir:o,base:i,ext:s,name:i.slice(0,i.length-s.length)}}export function renameFile(e,n){const r=parsePath(e);return p(r.dir,n.includes(".")?n:n+r.ext)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/path",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
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": {
|
|
@@ -9,12 +9,8 @@
|
|
|
9
9
|
"directory": "packages/path"
|
|
10
10
|
},
|
|
11
11
|
"private": false,
|
|
12
|
-
"dependencies": {
|
|
13
|
-
|
|
14
|
-
"mlly": "1.7.4",
|
|
15
|
-
"@stryke/types": ">=0.7.3"
|
|
16
|
-
},
|
|
17
|
-
"devDependencies": { "@stryke/types": "0.7.3", "@types/node": "^22.13.1" },
|
|
12
|
+
"dependencies": { "@storm-software/config-tools": "latest", "mlly": "1.7.4" },
|
|
13
|
+
"devDependencies": { "@stryke/types": "0.8.1", "@types/node": "^22.13.1" },
|
|
18
14
|
"publishConfig": { "access": "public" },
|
|
19
15
|
"sideEffects": false,
|
|
20
16
|
"files": ["dist/**/*"],
|