@stryke/path 0.13.0 → 0.13.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/dist/correct-path.cjs +5 -4
- package/dist/correct-path.mjs +1 -1
- package/dist/cwd.cjs +9 -0
- package/dist/cwd.d.ts +9 -0
- package/dist/cwd.mjs +1 -0
- package/dist/delimiter.cjs +6 -6
- package/dist/delimiter.d.ts +12 -2
- package/dist/delimiter.mjs +1 -1
- package/dist/file-path-fns.cjs +4 -7
- package/dist/file-path-fns.d.ts +0 -6
- package/dist/file-path-fns.mjs +1 -1
- package/dist/get-parent-path.cjs +14 -15
- package/dist/get-parent-path.d.ts +1 -1
- package/dist/get-parent-path.mjs +1 -1
- package/dist/index.cjs +11 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/replace.cjs +2 -1
- package/dist/replace.mjs +1 -1
- package/package.json +7 -16
- package/dist/is-file.cjs +0 -29
- package/dist/is-file.d.ts +0 -32
- package/dist/is-file.mjs +0 -1
package/dist/correct-path.cjs
CHANGED
|
@@ -8,6 +8,7 @@ exports.normalizeString = normalizeString;
|
|
|
8
8
|
exports.normalizeWindowsPath = normalizeWindowsPath;
|
|
9
9
|
exports.toAbsolutePath = toAbsolutePath;
|
|
10
10
|
exports.toRelativePath = toRelativePath;
|
|
11
|
+
var _cwd = require("./cwd.cjs");
|
|
11
12
|
var _isType = require("./is-type.cjs");
|
|
12
13
|
var _joinPaths = require("./join-paths.cjs");
|
|
13
14
|
var _regex = require("./regex.cjs");
|
|
@@ -38,8 +39,8 @@ function normalizeString(e, n) {
|
|
|
38
39
|
if (!(l === t - 1 || s === 1)) if (s === 2) {
|
|
39
40
|
if (r.length < 2 || i !== 2 || r[r.length - 1] !== "." || r[r.length - 2] !== ".") {
|
|
40
41
|
if (r.length > 2) {
|
|
41
|
-
const
|
|
42
|
-
|
|
42
|
+
const g = r.lastIndexOf("/");
|
|
43
|
+
g === -1 ? (r = "", i = 0) : (r = r.slice(0, g), i = r.length - 1 - r.lastIndexOf("/")), l = t, s = 0;
|
|
43
44
|
continue;
|
|
44
45
|
} else if (r.length > 0) {
|
|
45
46
|
r = "", i = 0, l = t, s = 0;
|
|
@@ -56,6 +57,6 @@ function normalizeString(e, n) {
|
|
|
56
57
|
function toAbsolutePath(e, n) {
|
|
57
58
|
return (0, _isType.isAbsolutePath)(e) ? e : (0, _slash.slash)(normalizeString((0, _joinPaths.joinPaths)(n || process.cwd(), e), !0));
|
|
58
59
|
}
|
|
59
|
-
function toRelativePath(e, n) {
|
|
60
|
-
return !e || e.length === 0 ? "." : ((0, _isType.isAbsolutePath)(e) ? e = (0, _slash.slash)(normalizeString(e, !0)) : e = (0, _slash.slash)(normalizeString((0, _joinPaths.joinPaths)(n
|
|
60
|
+
function toRelativePath(e, n = (0, _cwd.cwd)()) {
|
|
61
|
+
return !e || e.length === 0 ? "." : ((0, _isType.isAbsolutePath)(e) ? e = (0, _slash.slash)(normalizeString(e, !0)) : e = (0, _slash.slash)(normalizeString((0, _joinPaths.joinPaths)(n, e), !0)), e.startsWith("./") ? e.slice(2) : e);
|
|
61
62
|
}
|
package/dist/correct-path.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isAbsolutePath as
|
|
1
|
+
import{cwd as E}from"./cwd";import{isAbsolutePath as u}from"./is-type";import{joinPaths as c}from"./join-paths";import{DRIVE_LETTER_REGEX as m,DRIVE_LETTER_START_REGEX as d,UNC_REGEX as x}from"./regex";import{slash as f}from"./slash";export function normalizeWindowsPath(e=""){return e&&f(e).replace(d,n=>n.toUpperCase())}export function correctPath(e){if(!e||e.length===0)return".";e=normalizeWindowsPath(e);const n=e.match(x),r=u(e),i=e.endsWith("/");return e=normalizeString(e,!r),e.length===0?r?"/":i?"./":".":(i&&(e+="/"),m.test(e)&&(e+="/"),n?r?`//${e}`:`//./${e}`:!e.startsWith("/")&&r&&!m.test(e)?`/${e}`:e)}export function normalizeString(e,n){let r="",i=0,l=-1,s=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(!(l===t-1||s===1))if(s===2){if(r.length<2||i!==2||r[r.length-1]!=="."||r[r.length-2]!=="."){if(r.length>2){const g=r.lastIndexOf("/");g===-1?(r="",i=0):(r=r.slice(0,g),i=r.length-1-r.lastIndexOf("/")),l=t,s=0;continue}else if(r.length>0){r="",i=0,l=t,s=0;continue}}n&&(r+=r.length>0?"/..":"..",i=2)}else r.length>0?r+=`/${e.slice(l+1,t)}`:r=e.slice(l+1,t),i=t-l-1;l=t,s=0}else o==="."&&s!==-1?++s:s=-1}return r}export function toAbsolutePath(e,n){return u(e)?e:f(normalizeString(c(n||process.cwd(),e),!0))}export function toRelativePath(e,n=E()){return!e||e.length===0?".":(u(e)?e=f(normalizeString(e,!0)):e=f(normalizeString(c(n,e),!0)),e.startsWith("./")?e.slice(2):e)}
|
package/dist/cwd.cjs
ADDED
package/dist/cwd.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the current working directory.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This function attempts to retrieve the current working directory using `process.cwd()`.
|
|
6
|
+
*
|
|
7
|
+
* @returns The current working directory or '/' if it cannot be determined
|
|
8
|
+
*/
|
|
9
|
+
export declare function cwd(): string;
|
package/dist/cwd.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function cwd(){return typeof process<"u"&&typeof process.cwd=="function"?process.cwd().replace(/\\/g,"/"):"/"}
|
package/dist/delimiter.cjs
CHANGED
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.win32 = exports.posix = exports.delimiter = void 0;
|
|
7
7
|
const delimiter = exports.delimiter = process?.platform === "win32" ? ";" : ":";
|
|
8
|
-
const
|
|
8
|
+
const i = {
|
|
9
9
|
posix: void 0,
|
|
10
10
|
win32: void 0
|
|
11
11
|
},
|
|
12
|
-
|
|
13
|
-
get(
|
|
14
|
-
return
|
|
12
|
+
e = (t = delimiter) => new Proxy({}, {
|
|
13
|
+
get(o, n) {
|
|
14
|
+
return n === "delimiter" ? t : n === "posix" ? posix : n === "win32" ? win32 : i[n];
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
-
const posix = exports.posix =
|
|
18
|
-
win32 = exports.win32 =
|
|
17
|
+
const posix = exports.posix = e(":"),
|
|
18
|
+
win32 = exports.win32 = e(";");
|
package/dist/delimiter.d.ts
CHANGED
|
@@ -4,5 +4,15 @@
|
|
|
4
4
|
* Equals to `";"` in windows and `":"` in all other platforms.
|
|
5
5
|
*/
|
|
6
6
|
export declare const delimiter: ";" | ":";
|
|
7
|
-
export declare const posix:
|
|
8
|
-
|
|
7
|
+
export declare const posix: {
|
|
8
|
+
posix: any;
|
|
9
|
+
win32: any;
|
|
10
|
+
} & {
|
|
11
|
+
delimiter: ";" | ":";
|
|
12
|
+
};
|
|
13
|
+
export declare const win32: {
|
|
14
|
+
posix: any;
|
|
15
|
+
win32: any;
|
|
16
|
+
} & {
|
|
17
|
+
delimiter: ";" | ":";
|
|
18
|
+
};
|
package/dist/delimiter.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const delimiter=process?.platform==="win32"?";":":";const
|
|
1
|
+
export const delimiter=process?.platform==="win32"?";":":";const i={posix:void 0,win32:void 0},e=(t=delimiter)=>new Proxy({},{get(o,n){return n==="delimiter"?t:n==="posix"?posix:n==="win32"?win32:i[n]}});export const posix=e(":"),win32=e(";");
|
package/dist/file-path-fns.cjs
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.currentDir = currentDir;
|
|
7
6
|
exports.findFileExtension = findFileExtension;
|
|
8
7
|
exports.findFileExtensionSafe = findFileExtensionSafe;
|
|
9
8
|
exports.findFileName = findFileName;
|
|
@@ -23,6 +22,7 @@ exports.resolvePath = resolvePath;
|
|
|
23
22
|
exports.resolvePaths = resolvePaths;
|
|
24
23
|
var _base = require("@stryke/types/base");
|
|
25
24
|
var _correctPath = require("./correct-path.cjs");
|
|
25
|
+
var _cwd = require("./cwd.cjs");
|
|
26
26
|
var _isType = require("./is-type.cjs");
|
|
27
27
|
var _joinPaths = require("./join-paths.cjs");
|
|
28
28
|
var _regex = require("./regex.cjs");
|
|
@@ -73,7 +73,7 @@ function hasFolderName(e) {
|
|
|
73
73
|
function hasFileExtension(e) {
|
|
74
74
|
return !!findFileExtension(e);
|
|
75
75
|
}
|
|
76
|
-
function resolvePath(e, t =
|
|
76
|
+
function resolvePath(e, t = (0, _cwd.cwd)()) {
|
|
77
77
|
const r = (0, _correctPath.normalizeWindowsPath)(e).split("/");
|
|
78
78
|
let n = "",
|
|
79
79
|
i = !1;
|
|
@@ -88,7 +88,7 @@ function resolve(...e) {
|
|
|
88
88
|
let t = "",
|
|
89
89
|
r = !1;
|
|
90
90
|
for (let n = e.length - 1; n >= -1 && !r; n--) {
|
|
91
|
-
const i = n >= 0 ? e[n] :
|
|
91
|
+
const i = n >= 0 ? e[n] : (0, _cwd.cwd)();
|
|
92
92
|
!i || i.length === 0 || (t = `${i}/${t}`, r = (0, _isType.isAbsolute)(i));
|
|
93
93
|
}
|
|
94
94
|
return t = (0, _correctPath.normalizeString)(t, !r), r && !(0, _isType.isAbsolute)(t) ? `/${t}` : t.length > 0 ? t : ".";
|
|
@@ -96,9 +96,6 @@ function resolve(...e) {
|
|
|
96
96
|
function resolvePaths(...e) {
|
|
97
97
|
return resolvePath((0, _joinPaths.joinPaths)(...e.map(t => (0, _correctPath.normalizeWindowsPath)(t))));
|
|
98
98
|
}
|
|
99
|
-
function currentDir() {
|
|
100
|
-
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
101
|
-
}
|
|
102
99
|
function relative(e, t) {
|
|
103
100
|
const r = resolve(e).replace(_regex.ROOT_FOLDER_REGEX, "$1").split("/"),
|
|
104
101
|
n = resolve(t).replace(_regex.ROOT_FOLDER_REGEX, "$1").split("/");
|
|
@@ -114,7 +111,7 @@ function relativePath(e, t, r = !1) {
|
|
|
114
111
|
return relative(r !== !0 ? e.replace(/\/$/, "") : e, r !== !0 ? t.replace(/\/$/, "") : t);
|
|
115
112
|
}
|
|
116
113
|
function relativeToCurrentDir(e) {
|
|
117
|
-
return relativePath(e,
|
|
114
|
+
return relativePath(e, (0, _cwd.cwd)());
|
|
118
115
|
}
|
|
119
116
|
function parsePath(e) {
|
|
120
117
|
const t = /^[/\\]|^[a-z]:[/\\]/i.exec(e)?.[0]?.replace(/\\/g, "/") || "",
|
package/dist/file-path-fns.d.ts
CHANGED
|
@@ -125,12 +125,6 @@ export declare function resolve(...paths: string[]): string;
|
|
|
125
125
|
* @returns The resolved path
|
|
126
126
|
*/
|
|
127
127
|
export declare function resolvePaths(...paths: string[]): string;
|
|
128
|
-
/**
|
|
129
|
-
* Get the current working directory.
|
|
130
|
-
*
|
|
131
|
-
* @returns The current working directory or '/' if it cannot be determined
|
|
132
|
-
*/
|
|
133
|
-
export declare function currentDir(): string;
|
|
134
128
|
/**
|
|
135
129
|
* Get the relative path from one file to another.
|
|
136
130
|
*
|
package/dist/file-path-fns.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EMPTY_STRING as u}from"@stryke/types/base";import{normalizeString as
|
|
1
|
+
import{EMPTY_STRING as u}from"@stryke/types/base";import{normalizeString as g,normalizeWindowsPath as l}from"./correct-path";import{cwd as a}from"./cwd";import{isAbsolute as p,isAbsolutePath as c}from"./is-type";import{joinPaths as f}from"./join-paths";import{ROOT_FOLDER_REGEX as d}from"./regex";export function findFileName(e,t={}){const{requireExtension:r=!1,withExtension:n=!0}=t,i=l(e)?.split(e?.includes("\\")?"\\":"/")?.pop()??"";return r===!0&&!i.includes(".")?u:n===!1&&i.includes(".")?i.substring(0,i.lastIndexOf("."))||u:i}export function findFilePath(e){const t=l(e),r=t.replace(findFileName(t,{requireExtension:!0}),"");return r==="/"?r:r.replace(/\/$/,"")}export function findFolderName(e){const t=findFilePath(e).split("/");let r="";for(let n=t.length-1;n>=0;n--){const i=t[n];if(i){r=i;break}}return r??u}export function findFileExtension(e){if(e.endsWith(".")||e.endsWith("/"))return;const t=/.(\.[^./]+|\.)$/.exec(l(e));return t&&t[1]||void 0}export function findFileExtensionSafe(e){return findFileExtension(e)??u}export function hasFileName(e){return!!findFileName(e)}export function hasFilePath(e){return!!findFilePath(e)}export function hasFolderName(e){return!!findFolderName(e)}export function hasFileExtension(e){return!!findFileExtension(e)}export function resolvePath(e,t=a()){const r=l(e).split("/");let n="",i=!1;for(let o=r.length-1;o>=-1&&!i;o--){const s=o>=0?r[o]:t;!s||s.length===0||(n=f(s,n),i=c(s))}return n=g(n,!i),i&&!c(n)?`/${n}`:n.length>0?n:"."}export function resolve(...e){e=e.map(n=>l(n));let t="",r=!1;for(let n=e.length-1;n>=-1&&!r;n--){const i=n>=0?e[n]:a();!i||i.length===0||(t=`${i}/${t}`,r=p(i))}return t=g(t,!r),r&&!p(t)?`/${t}`:t.length>0?t:"."}export function resolvePaths(...e){return resolvePath(f(...e.map(t=>l(t))))}export function relative(e,t){const r=resolve(e).replace(d,"$1").split("/"),n=resolve(t).replace(d,"$1").split("/");if(n[0][1]===":"&&r[0][1]===":"&&r[0]!==n[0])return n.join("/");const i=[...r];for(const o of i){if(n[0]!==o)break;r.shift(),n.shift()}return[...r.map(()=>".."),...n].join("/")}export function relativePath(e,t,r=!1){return relative(r!==!0?e.replace(/\/$/,""):e,r!==!0?t.replace(/\/$/,""):t)}export function relativeToCurrentDir(e){return relativePath(e,a())}export function parsePath(e){const t=/^[/\\]|^[a-z]:[/\\]/i.exec(e)?.[0]?.replace(/\\/g,"/")||"",r=l(e),n=r.replace(/\/$/,"").split("/").slice(0,-1);n.length===1&&/^[A-Z]:$/i.test(n[0])&&(n[0]+="/");const i=findFolderName(r),o=n.join("/")||(c(e)?"/":"."),s=findFileExtensionSafe(e);return{root:t,dir:o,base:i,ext:s,name:i.slice(0,i.length-s.length)}}export function renameFile(e,t){const r=parsePath(e);return f(r.dir,t.includes(".")?t:t+r.ext)}
|
package/dist/get-parent-path.cjs
CHANGED
|
@@ -4,26 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.resolveParentPath = exports.getParentPath = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _cwd = require("./cwd.cjs");
|
|
8
8
|
var _joinPaths = require("./join-paths.cjs");
|
|
9
|
-
const resolveParentPath = (r,
|
|
9
|
+
const resolveParentPath = (r, n = 1) => {
|
|
10
10
|
let t = r.replaceAll(/\/+$/g, "");
|
|
11
|
-
for (let
|
|
11
|
+
for (let i = 0; i < n; i++) t = (0, _joinPaths.joinPaths)(t, "..");
|
|
12
12
|
return t;
|
|
13
13
|
},
|
|
14
|
-
getParentPath = (r,
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const a = l.find(p => (0, _isFile.isFile)((0, _joinPaths.joinPaths)(e, p)) && (o === "file" || o === "both") || (0, _isFile.isDirectory)((0, _joinPaths.joinPaths)(e, p)) && (o === "directory" || o === "both"));
|
|
14
|
+
getParentPath = (r, n = (0, _cwd.cwd)(), t = {}) => {
|
|
15
|
+
const i = t?.ignoreCase ?? !0,
|
|
16
|
+
p = t?.skipCwd ?? !1;
|
|
17
|
+
let e = n;
|
|
18
|
+
p && (e = resolveParentPath(n));
|
|
19
|
+
let o = Array.isArray(r) ? r : [r];
|
|
20
|
+
for (i && (o = o.map(a => a.toLowerCase()));;) {
|
|
21
|
+
const a = o.find(f => (0, _joinPaths.joinPaths)(e, f));
|
|
23
22
|
if (a) return (0, _joinPaths.joinPaths)(e, a);
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
e =
|
|
23
|
+
const l = resolveParentPath(e);
|
|
24
|
+
if (l === e) return;
|
|
25
|
+
e = l;
|
|
27
26
|
}
|
|
28
27
|
};
|
|
29
28
|
exports.getParentPath = getParentPath;
|
|
@@ -36,4 +36,4 @@ export interface GetParentPathOptions {
|
|
|
36
36
|
* @param cwd - The current working directory.
|
|
37
37
|
* @returns The first parent path that exists.
|
|
38
38
|
*/
|
|
39
|
-
export declare const getParentPath: (name: string | string[], cwd
|
|
39
|
+
export declare const getParentPath: (name: string | string[], cwd?: string, options?: Partial<GetParentPathOptions>) => string | undefined;
|
package/dist/get-parent-path.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{cwd as g}from"./cwd";import{joinPaths as s}from"./join-paths";export const resolveParentPath=(r,n=1)=>{let t=r.replaceAll(/\/+$/g,"");for(let i=0;i<n;i++)t=s(t,"..");return t},getParentPath=(r,n=g(),t={})=>{const i=t?.ignoreCase??!0,p=t?.skipCwd??!1;let e=n;p&&(e=resolveParentPath(n));let o=Array.isArray(r)?r:[r];for(i&&(o=o.map(a=>a.toLowerCase()));;){const a=o.find(f=>s(e,f));if(a)return s(e,a);const l=resolveParentPath(e);if(l===e)return;e=l}};
|
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,17 @@ Object.keys(_correctPath).forEach(function (key) {
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
+
var _cwd = require("./cwd.cjs");
|
|
29
|
+
Object.keys(_cwd).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _cwd[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _cwd[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
28
39
|
var _delimiter = require("./delimiter.cjs");
|
|
29
40
|
Object.keys(_delimiter).forEach(function (key) {
|
|
30
41
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -58,17 +69,6 @@ Object.keys(_getParentPath).forEach(function (key) {
|
|
|
58
69
|
}
|
|
59
70
|
});
|
|
60
71
|
});
|
|
61
|
-
var _isFile = require("./is-file.cjs");
|
|
62
|
-
Object.keys(_isFile).forEach(function (key) {
|
|
63
|
-
if (key === "default" || key === "__esModule") return;
|
|
64
|
-
if (key in exports && exports[key] === _isFile[key]) return;
|
|
65
|
-
Object.defineProperty(exports, key, {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () {
|
|
68
|
-
return _isFile[key];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
72
|
var _isParentPath = require("./is-parent-path.cjs");
|
|
73
73
|
Object.keys(_isParentPath).forEach(function (key) {
|
|
74
74
|
if (key === "default" || key === "__esModule") return;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export * from "./asset-extensions";
|
|
10
10
|
export * from "./correct-path";
|
|
11
|
+
export * from "./cwd";
|
|
11
12
|
export * from "./delimiter";
|
|
12
13
|
export * from "./file-path-fns";
|
|
13
14
|
export * from "./get-parent-path";
|
|
14
|
-
export * from "./is-file";
|
|
15
15
|
export * from "./is-parent-path";
|
|
16
16
|
export * from "./is-root-dir";
|
|
17
17
|
export * from "./join-paths";
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./asset-extensions";export*from"./correct-path";export*from"./delimiter";export*from"./file-path-fns";export*from"./get-parent-path";export*from"./is-
|
|
1
|
+
export*from"./asset-extensions";export*from"./correct-path";export*from"./cwd";export*from"./delimiter";export*from"./file-path-fns";export*from"./get-parent-path";export*from"./is-parent-path";export*from"./is-root-dir";export*from"./join-paths";export*from"./regex";export*from"./replace";export*from"./slash";
|
package/dist/replace.cjs
CHANGED
|
@@ -4,8 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.replacePath = replacePath;
|
|
7
|
+
var _cwd = require("./cwd.cjs");
|
|
7
8
|
var _isParentPath = require("./is-parent-path.cjs");
|
|
8
9
|
var _slash = require("./slash.cjs");
|
|
9
|
-
function replacePath(r, e =
|
|
10
|
+
function replacePath(r, e = (0, _cwd.cwd)()) {
|
|
10
11
|
return (0, _isParentPath.isParentPath)(r, e) ? (0, _slash.slash)(r).replace((0, _slash.slash)(e), "").replace(/^\//, "") : r;
|
|
11
12
|
}
|
package/dist/replace.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isParentPath as
|
|
1
|
+
import{cwd as t}from"./cwd";import{isParentPath as i}from"./is-parent-path";import{slash as o}from"./slash";export function replacePath(r,e=t()){return i(r,e)?o(r).replace(o(e),"").replace(/^\//,""):r}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/path",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
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": {
|
|
@@ -141,20 +141,6 @@
|
|
|
141
141
|
"default": "./dist/is-parent-path.mjs"
|
|
142
142
|
}
|
|
143
143
|
},
|
|
144
|
-
"./is-file": {
|
|
145
|
-
"import": {
|
|
146
|
-
"types": "./dist/is-file.d.ts",
|
|
147
|
-
"default": "./dist/is-file.mjs"
|
|
148
|
-
},
|
|
149
|
-
"require": {
|
|
150
|
-
"types": "./dist/is-file.d.ts",
|
|
151
|
-
"default": "./dist/is-file.cjs"
|
|
152
|
-
},
|
|
153
|
-
"default": {
|
|
154
|
-
"types": "./dist/is-file.d.ts",
|
|
155
|
-
"default": "./dist/is-file.mjs"
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
144
|
"./index": {
|
|
159
145
|
"import": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" },
|
|
160
146
|
"require": {
|
|
@@ -205,6 +191,11 @@
|
|
|
205
191
|
"default": "./dist/delimiter.mjs"
|
|
206
192
|
}
|
|
207
193
|
},
|
|
194
|
+
"./cwd": {
|
|
195
|
+
"import": { "types": "./dist/cwd.d.ts", "default": "./dist/cwd.mjs" },
|
|
196
|
+
"require": { "types": "./dist/cwd.d.ts", "default": "./dist/cwd.cjs" },
|
|
197
|
+
"default": { "types": "./dist/cwd.d.ts", "default": "./dist/cwd.mjs" }
|
|
198
|
+
},
|
|
208
199
|
"./correct-path": {
|
|
209
200
|
"import": {
|
|
210
201
|
"types": "./dist/correct-path.d.ts",
|
|
@@ -246,5 +237,5 @@
|
|
|
246
237
|
"main": "./dist/index.cjs",
|
|
247
238
|
"module": "./dist/index.mjs",
|
|
248
239
|
"types": "./dist/index.d.ts",
|
|
249
|
-
"gitHead": "
|
|
240
|
+
"gitHead": "7ec1f888f4eb3038ac5316409189322fda2e5aa6"
|
|
250
241
|
}
|
package/dist/is-file.cjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isDirectory = isDirectory;
|
|
7
|
-
exports.isDirectorySymlink = void 0;
|
|
8
|
-
exports.isFile = isFile;
|
|
9
|
-
exports.isFileSymlink = void 0;
|
|
10
|
-
var _nodeFs = require("node:fs");
|
|
11
|
-
var _joinPaths = require("./join-paths.cjs");
|
|
12
|
-
function isFile(r, o) {
|
|
13
|
-
return !!(0, _nodeFs.statSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
|
|
14
|
-
throwIfNoEntry: !1
|
|
15
|
-
})?.isFile();
|
|
16
|
-
}
|
|
17
|
-
function isDirectory(r, o) {
|
|
18
|
-
return !!(0, _nodeFs.statSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
|
|
19
|
-
throwIfNoEntry: !1
|
|
20
|
-
})?.isDirectory();
|
|
21
|
-
}
|
|
22
|
-
const isFileSymlink = (r, o) => !!(0, _nodeFs.lstatSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
|
|
23
|
-
throwIfNoEntry: !1
|
|
24
|
-
})?.isFile(),
|
|
25
|
-
isDirectorySymlink = (r, o) => !!(0, _nodeFs.lstatSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
|
|
26
|
-
throwIfNoEntry: !1
|
|
27
|
-
})?.isDirectory();
|
|
28
|
-
exports.isDirectorySymlink = isDirectorySymlink;
|
|
29
|
-
exports.isFileSymlink = isFileSymlink;
|
package/dist/is-file.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if the given path is a file.
|
|
3
|
-
*
|
|
4
|
-
* @param path - The location to check
|
|
5
|
-
* @param additionalPath - An optional additional path to add to the start of the path
|
|
6
|
-
* @returns An indicator specifying if the path is a file
|
|
7
|
-
*/
|
|
8
|
-
export declare function isFile(path: string, additionalPath?: string): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Check if the given path is a directory.
|
|
11
|
-
*
|
|
12
|
-
* @param path - The location to check
|
|
13
|
-
* @param additionalPath - An optional additional path to add to the start of the path
|
|
14
|
-
* @returns An indicator specifying if the path is a directory
|
|
15
|
-
*/
|
|
16
|
-
export declare function isDirectory(path: string, additionalPath?: string): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Check if the given path is a file . Does not dereference symbolic links.
|
|
19
|
-
*
|
|
20
|
-
* @param path - The location to check
|
|
21
|
-
* @param additionalPath - An optional additional path to add to the start of the path
|
|
22
|
-
* @returns An indicator specifying if the path is a file
|
|
23
|
-
*/
|
|
24
|
-
export declare const isFileSymlink: (path: string, additionalPath?: string) => boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Check if the given path is a directory. Does not dereference symbolic links.
|
|
27
|
-
*
|
|
28
|
-
* @param path - The location to check
|
|
29
|
-
* @param additionalPath - An optional additional path to add to the start of the path
|
|
30
|
-
* @returns An indicator specifying if the path is a directory
|
|
31
|
-
*/
|
|
32
|
-
export declare const isDirectorySymlink: (path: string, additionalPath?: string) => boolean;
|
package/dist/is-file.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{lstatSync as e,statSync as t}from"node:fs";import{joinPaths as n}from"./join-paths";export function isFile(r,o){return!!t(o?n(o,r):r,{throwIfNoEntry:!1})?.isFile()}export function isDirectory(r,o){return!!t(o?n(o,r):r,{throwIfNoEntry:!1})?.isDirectory()}export const isFileSymlink=(r,o)=>!!e(o?n(o,r):r,{throwIfNoEntry:!1})?.isFile(),isDirectorySymlink=(r,o)=>!!e(o?n(o,r):r,{throwIfNoEntry:!1})?.isDirectory();
|