@stryke/path 0.18.2 → 0.18.3

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/append.cjs CHANGED
@@ -10,6 +10,6 @@ var _isParentPath = require("./is-parent-path.cjs");
10
10
  var _joinPaths = require("./join-paths.cjs");
11
11
  var _slash = require("./slash.cjs");
12
12
  function appendPath(r, o = (0, _cwd.cwd)()) {
13
- return (0, _slash.slash)((0, _isParentPath.isParentPath)(r, o) ? r : (0, _joinPaths.joinPaths)(o, r));
13
+ return (0, _slash.formatSlash)((0, _isParentPath.isParentPath)(r, o) ? r : (0, _joinPaths.joinPaths)(o, r));
14
14
  }
15
15
  const append = exports.append = appendPath;
package/dist/append.mjs CHANGED
@@ -1 +1 @@
1
- import{cwd as t}from"./cwd";import{isParentPath as n}from"./is-parent-path";import{joinPaths as p}from"./join-paths";import{slash as i}from"./slash";export function appendPath(r,o=t()){return i(n(r,o)?r:p(o,r))}export const append=appendPath;
1
+ import{cwd as t}from"./cwd";import{isParentPath as n}from"./is-parent-path";import{joinPaths as m}from"./join-paths";import{formatSlash as p}from"./slash";export function appendPath(r,o=t()){return p(n(r,o)?r:m(o,r))}export const append=appendPath;
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isParentPath = isParentPath;
7
7
  var _slash = require("./slash.cjs");
8
- function isParentPath(l, c) {
9
- const e = (0, _slash.slash)(l.replace(/\/+/g, "/").replace(/\/+$/, "")),
10
- r = (0, _slash.slash)(c.replace(/\/+/g, "/").replace(/\/+$/, ""));
11
- return e.replace(/^\/+/g, "").replace(/\/+$/g, "") !== r.replace(/^\/+/g, "").replace(/\/+$/g, "") && e.replace(/^\/+/g, "").replace(/\/+$/g, "").startsWith(r.replace(/^\/+/g, "").replace(/\/+$/g, ""));
8
+ function isParentPath(o, a) {
9
+ const r = (0, _slash.formatSlash)(o),
10
+ n = (0, _slash.formatSlash)(a);
11
+ return (0, _slash.formatSlash)(r) !== (0, _slash.formatSlash)(n) && (0, _slash.formatSlash)(r).startsWith((0, _slash.formatSlash)(n));
12
12
  }
@@ -1 +1 @@
1
- import{slash as a}from"./slash";export function isParentPath(l,c){const e=a(l.replace(/\/+/g,"/").replace(/\/+$/,"")),r=a(c.replace(/\/+/g,"/").replace(/\/+$/,""));return e.replace(/^\/+/g,"").replace(/\/+$/g,"")!==r.replace(/^\/+/g,"").replace(/\/+$/g,"")&&e.replace(/^\/+/g,"").replace(/\/+$/g,"").startsWith(r.replace(/^\/+/g,"").replace(/\/+$/g,""))}
1
+ import{formatSlash as t}from"./slash";export function isParentPath(o,a){const r=t(o),n=t(a);return t(r)!==t(n)&&t(r).startsWith(t(n))}
package/dist/replace.cjs CHANGED
@@ -10,9 +10,9 @@ var _cwd = require("./cwd.cjs");
10
10
  var _filePathFns = require("./file-path-fns.cjs");
11
11
  var _isParentPath = require("./is-parent-path.cjs");
12
12
  var _slash = require("./slash.cjs");
13
- function replacePath(r, e = (0, _cwd.cwd)()) {
14
- return (0, _correctPath.correctPath)((0, _isParentPath.isParentPath)(r, e) ? (0, _slash.slash)(r).replace(/^\/+/g, "").replace(/\/+$/g, "").replace((0, _slash.slash)(e).replace(/^\/+/g, "").replace(/\/+$/g, ""), "") : r);
13
+ function replacePath(r, o = (0, _cwd.cwd)()) {
14
+ return (0, _slash.formatSlash)((0, _correctPath.correctPath)((0, _isParentPath.isParentPath)(r, o) ? (0, _slash.formatSlash)(r).replace((0, _slash.formatSlash)(o), "") : r));
15
15
  }
16
- function replaceExtension(r, e = "") {
17
- return (0, _correctPath.correctPath)(r.replace(!e || e.includes(".") ? (0, _filePathFns.findFileDotExtensionSafe)(r) : (0, _filePathFns.findFileExtensionSafe)(r), e));
16
+ function replaceExtension(r, o = "") {
17
+ return (0, _correctPath.correctPath)(r.replace(!o || o.includes(".") ? (0, _filePathFns.findFileDotExtensionSafe)(r) : (0, _filePathFns.findFileExtensionSafe)(r), o));
18
18
  }
package/dist/replace.mjs CHANGED
@@ -1 +1 @@
1
- import{correctPath as i}from"./correct-path";import{cwd as n}from"./cwd";import{findFileDotExtensionSafe as t,findFileExtensionSafe as s}from"./file-path-fns";import{isParentPath as f}from"./is-parent-path";import{slash as o}from"./slash";export function replacePath(r,e=n()){return i(f(r,e)?o(r).replace(/^\/+/g,"").replace(/\/+$/g,"").replace(o(e).replace(/^\/+/g,"").replace(/\/+$/g,""),""):r)}export function replaceExtension(r,e=""){return i(r.replace(!e||e.includes(".")?t(r):s(r),e))}
1
+ import{correctPath as n}from"./correct-path";import{cwd as t}from"./cwd";import{findFileDotExtensionSafe as e,findFileExtensionSafe as f}from"./file-path-fns";import{isParentPath as s}from"./is-parent-path";import{formatSlash as i}from"./slash";export function replacePath(r,o=t()){return i(n(s(r,o)?i(r).replace(i(o),""):r))}export function replaceExtension(r,o=""){return n(r.replace(!o||o.includes(".")?e(r):f(r),o))}
package/dist/slash.cjs CHANGED
@@ -3,7 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.formatSlash = formatSlash;
6
7
  exports.slash = slash;
8
+ var _isType = require("./is-type.cjs");
7
9
  function slash(r) {
8
10
  return r.startsWith("\\\\?\\") ? r : r.replace(/\\/g, "/");
11
+ }
12
+ function formatSlash(r) {
13
+ const t = slash(r);
14
+ return (0, _isType.isAbsolutePath)(t) ? t.replace(/\/+$/g, "") : t.replace(/^\.\//g, "").replace(/\/+$/g, "");
9
15
  }
package/dist/slash.d.ts CHANGED
@@ -5,3 +5,10 @@
5
5
  * @returns The string with replaced backslashes
6
6
  */
7
7
  export declare function slash(path: string): string;
8
+ /**
9
+ * Replace backslash to slash and remove unneeded leading and trailing slashes
10
+ *
11
+ * @param path - The string to replace
12
+ * @returns The string with replaced backslashes
13
+ */
14
+ export declare function formatSlash(path: string): string;
package/dist/slash.mjs CHANGED
@@ -1 +1 @@
1
- export function slash(r){return r.startsWith("\\\\?\\")?r:r.replace(/\\/g,"/")}
1
+ import{isAbsolutePath as e}from"./is-type";export function slash(r){return r.startsWith("\\\\?\\")?r:r.replace(/\\/g,"/")}export function formatSlash(r){const t=slash(r);return e(t)?t.replace(/\/+$/g,""):t.replace(/^\.\//g,"").replace(/\/+$/g,"")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/path",
3
- "version": "0.18.2",
3
+ "version": "0.18.3",
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": {
@@ -294,5 +294,5 @@
294
294
  "main": "./dist/index.cjs",
295
295
  "module": "./dist/index.mjs",
296
296
  "types": "./dist/index.d.ts",
297
- "gitHead": "b72f1ffff997334f9986d1dea1124e720cf71ff4"
297
+ "gitHead": "318f947b4a5068b62181d287cfa768f711d2e95e"
298
298
  }