@stryke/path 0.7.0 → 0.7.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.
@@ -8,20 +8,20 @@ var _filePathFns = require("./file-path-fns.cjs");
8
8
  var _isFile = require("./is-file.cjs");
9
9
  var _joinPaths = require("./join-paths.cjs");
10
10
  const resolveParentPath = (r, i = 1) => {
11
- let t = r;
11
+ let t = r.replaceAll(/\/+$/g, "");
12
12
  for (let o = 0; o < i; o++) t = (0, _filePathFns.resolvePaths)(t, "..");
13
13
  return t;
14
14
  },
15
15
  getParentPath = (r, i, t) => {
16
16
  const o = t?.ignoreCase ?? !0,
17
- l = t?.skipCwd ?? !1,
17
+ g = t?.skipCwd ?? !1,
18
18
  n = t?.targetType ?? "both";
19
19
  let e = i;
20
- l && (e = resolveParentPath(i));
21
- let a = Array.isArray(r) ? r : [r];
22
- for (o && (a = a.map(s => s.toLowerCase()));;) {
23
- const s = a.find(g => (0, _isFile.isFile)((0, _joinPaths.joinPaths)(e, g)) && (n === "file" || n === "both") || (0, _isFile.isDirectory)((0, _joinPaths.joinPaths)(e, g)) && (n === "directory" || n === "both"));
24
- if (s) return (0, _joinPaths.joinPaths)(e, s);
20
+ g && (e = resolveParentPath(i));
21
+ let s = Array.isArray(r) ? r : [r];
22
+ for (o && (s = s.map(a => a.toLowerCase()));;) {
23
+ const a = s.find(f => (0, _isFile.isFile)((0, _joinPaths.joinPaths)(e, f)) && (n === "file" || n === "both") || (0, _isFile.isDirectory)((0, _joinPaths.joinPaths)(e, f)) && (n === "directory" || n === "both"));
24
+ if (a) return (0, _joinPaths.joinPaths)(e, a);
25
25
  const p = resolveParentPath(e);
26
26
  if (p === e) return;
27
27
  e = p;
@@ -1 +1 @@
1
- import{resolvePaths as h}from"./file-path-fns";import{isDirectory as P,isFile as c}from"./is-file";import{joinPaths as f}from"./join-paths";export const resolveParentPath=(r,i=1)=>{let t=r;for(let o=0;o<i;o++)t=h(t,"..");return t},getParentPath=(r,i,t)=>{const o=t?.ignoreCase??!0,l=t?.skipCwd??!1,n=t?.targetType??"both";let e=i;l&&(e=resolveParentPath(i));let a=Array.isArray(r)?r:[r];for(o&&(a=a.map(s=>s.toLowerCase()));;){const s=a.find(g=>c(f(e,g))&&(n==="file"||n==="both")||P(f(e,g))&&(n==="directory"||n==="both"));if(s)return f(e,s);const p=resolveParentPath(e);if(p===e)return;e=p}};
1
+ import{resolvePaths as h}from"./file-path-fns";import{isDirectory as P,isFile as c}from"./is-file";import{joinPaths as l}from"./join-paths";export const resolveParentPath=(r,i=1)=>{let t=r.replaceAll(/\/+$/g,"");for(let o=0;o<i;o++)t=h(t,"..");return t},getParentPath=(r,i,t)=>{const o=t?.ignoreCase??!0,g=t?.skipCwd??!1,n=t?.targetType??"both";let e=i;g&&(e=resolveParentPath(i));let s=Array.isArray(r)?r:[r];for(o&&(s=s.map(a=>a.toLowerCase()));;){const a=s.find(f=>c(l(e,f))&&(n==="file"||n==="both")||P(l(e,f))&&(n==="directory"||n==="both"));if(a)return l(e,a);const p=resolveParentPath(e);if(p===e)return;e=p}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/path",
3
- "version": "0.7.0",
3
+ "version": "0.7.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": {