@stryke/path 0.11.0 → 0.12.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/index.cjs +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/is-parent-path.cjs +12 -0
- package/dist/is-parent-path.d.ts +22 -0
- package/dist/is-parent-path.mjs +1 -0
- package/dist/replace.cjs +3 -2
- package/dist/replace.d.ts +4 -4
- package/dist/replace.mjs +1 -1
- package/dist/resolve.cjs +1 -1
- package/dist/resolve.d.ts +1 -1
- package/dist/resolve.mjs +1 -1
- package/package.json +16 -2
package/dist/index.cjs
CHANGED
|
@@ -91,6 +91,17 @@ Object.keys(_isFile).forEach(function (key) {
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
|
+
var _isParentPath = require("./is-parent-path.cjs");
|
|
95
|
+
Object.keys(_isParentPath).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _isParentPath[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _isParentPath[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
94
105
|
var _isRootDir = require("./is-root-dir.cjs");
|
|
95
106
|
Object.keys(_isRootDir).forEach(function (key) {
|
|
96
107
|
if (key === "default" || key === "__esModule") return;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./file-path-fns";
|
|
|
14
14
|
export * from "./get-parent-path";
|
|
15
15
|
export * from "./get-workspace-root";
|
|
16
16
|
export * from "./is-file";
|
|
17
|
+
export * from "./is-parent-path";
|
|
17
18
|
export * from "./is-root-dir";
|
|
18
19
|
export * from "./join-paths";
|
|
19
20
|
export * from "./regex";
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./asset-extensions";export*from"./correct-path";export*from"./delimiter";export*from"./exists";export*from"./file-path-fns";export*from"./get-parent-path";export*from"./get-workspace-root";export*from"./is-file";export*from"./is-root-dir";export*from"./join-paths";export*from"./regex";export*from"./replace";export*from"./resolve";export*from"./slash";
|
|
1
|
+
export*from"./asset-extensions";export*from"./correct-path";export*from"./delimiter";export*from"./exists";export*from"./file-path-fns";export*from"./get-parent-path";export*from"./get-workspace-root";export*from"./is-file";export*from"./is-parent-path";export*from"./is-root-dir";export*from"./join-paths";export*from"./regex";export*from"./replace";export*from"./resolve";export*from"./slash";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isParentPath = isParentPath;
|
|
7
|
+
var _slash = require("./slash.cjs");
|
|
8
|
+
function isParentPath(a, n) {
|
|
9
|
+
const r = (0, _slash.slash)(a.replace(/\\/g, "/").replace(/\/$/, "")),
|
|
10
|
+
e = (0, _slash.slash)(n.replace(/\\/g, "/").replace(/\/$/, ""));
|
|
11
|
+
return r !== e && r.startsWith(`${e}/`);
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a given path is a parent of another path.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* isParentPath("/home/user/project/src/index.ts", "/home/user/project/src");
|
|
7
|
+
* // returns true
|
|
8
|
+
* isParentPath("/home/user/project/src/index.ts", "/home/user/project");
|
|
9
|
+
* // returns true
|
|
10
|
+
* isParentPath("/home/user/project/src/index.ts", "/home/user/project/src/other");
|
|
11
|
+
* // returns false
|
|
12
|
+
* isParentPath("/home/user/project/src/index.ts", "/home/user/other");
|
|
13
|
+
* // returns false
|
|
14
|
+
* isParentPath("/home/user/project/src/index.ts", "/home/user/project/src/index.ts");
|
|
15
|
+
* // returns false
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param childPath - The path to check if it is a child of the parent path.
|
|
19
|
+
* @param parentPath - The path to check if it is a parent of the child path.
|
|
20
|
+
* @returns `true` if `childPath` is a child of `parentPath`, otherwise `false`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isParentPath(childPath: string, parentPath: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{slash as t}from"./slash";export function isParentPath(a,n){const r=t(a.replace(/\\/g,"/").replace(/\/$/,"")),e=t(n.replace(/\\/g,"/").replace(/\/$/,""));return r!==e&&r.startsWith(`${e}/`)}
|
package/dist/replace.cjs
CHANGED
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.replacePath = replacePath;
|
|
7
|
+
var _isParentPath = require("./is-parent-path.cjs");
|
|
7
8
|
var _slash = require("./slash.cjs");
|
|
8
|
-
function replacePath(
|
|
9
|
-
return (0, _slash.slash)(
|
|
9
|
+
function replacePath(r, e = process.cwd()) {
|
|
10
|
+
return (0, _isParentPath.isParentPath)(r, e) ? (0, _slash.slash)(r).replace((0, _slash.slash)(e), "").replace(/^\//, "") : r;
|
|
10
11
|
}
|
package/dist/replace.d.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* // returns "src/index.ts"
|
|
8
8
|
* ```
|
|
9
9
|
*
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @returns The {@link
|
|
10
|
+
* @param childPath - The child path to replace the {@link parentPath} substring from
|
|
11
|
+
* @param parentPath - The parent path to remove from the {@link childPath} parameter
|
|
12
|
+
* @returns The {@link childPath} with the {@link parentPath} path removed
|
|
13
13
|
*/
|
|
14
|
-
export declare function replacePath(
|
|
14
|
+
export declare function replacePath(childPath: string, parentPath?: string): string;
|
package/dist/replace.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{slash as
|
|
1
|
+
import{isParentPath as o}from"./is-parent-path";import{slash as s}from"./slash";export function replacePath(r,e=process.cwd()){return o(r,e)?s(r).replace(s(e),"").replace(/^\//,""):r}
|
package/dist/resolve.cjs
CHANGED
|
@@ -53,7 +53,7 @@ async function resolvePackage(r, e = {}) {
|
|
|
53
53
|
let t = await resolveSafe((0, _joinPaths.joinPaths)(r, "package.json"), e);
|
|
54
54
|
return t || (t = await resolveSafe((0, _joinPaths.joinPaths)(r, "index.js"), e), t || (t = await resolveSafe(r, e))), t ? (0, _filePathFns.findFilePath)(t) : void 0;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
function resolvePackageSync(r, e = {}) {
|
|
57
57
|
let t = resolveSafeSync((0, _joinPaths.joinPaths)(r, "package.json"), e);
|
|
58
58
|
return t || (t = resolveSafeSync((0, _joinPaths.joinPaths)(r, "index.js"), e), t || (t = resolveSafeSync(r, e))), t ? (0, _filePathFns.findFilePath)(t) : void 0;
|
|
59
59
|
}
|
package/dist/resolve.d.ts
CHANGED
|
@@ -68,4 +68,4 @@ export declare function resolvePackage(name: string, options?: PackageResolvingO
|
|
|
68
68
|
* @param options - The options to use when resolving the module
|
|
69
69
|
* @returns The module or undefined
|
|
70
70
|
*/
|
|
71
|
-
export declare function resolvePackageSync(name: string, options?: PackageResolvingOptions):
|
|
71
|
+
export declare function resolvePackageSync(name: string, options?: PackageResolvingOptions): string | undefined;
|
package/dist/resolve.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{interopDefault as c,resolvePath as p,resolvePathSync as f}from"mlly";import{correctPath as s}from"./correct-path";import{findFilePath as i}from"./file-path-fns";import{getWorkspaceRoot as a}from"./get-workspace-root";import{joinPaths as o}from"./join-paths";export async function resolve(r,e={}){const t=e.paths??[];t.length===0&&t.push(process.cwd());const n=a();return t.includes(n)||t.push(n),s(await p(r,{url:t}))}export function resolveSync(r,e={}){const t=e.paths??[];t.length===0&&t.push(process.cwd());const n=a();return t.includes(n)||t.push(n),s(f(r,{url:e.paths}))}export async function resolveSafe(r,e={}){try{return await resolve(r,e)}catch{return}}export function resolveSafeSync(r,e={}){try{return resolveSync(r,e)}catch{return}}export async function importModule(r){const e=await import(r);return e&&c(e)}export async function resolvePackage(r,e={}){let t=await resolveSafe(o(r,"package.json"),e);return t||(t=await resolveSafe(o(r,"index.js"),e),t||(t=await resolveSafe(r,e))),t?i(t):void 0}export
|
|
1
|
+
import{interopDefault as c,resolvePath as p,resolvePathSync as f}from"mlly";import{correctPath as s}from"./correct-path";import{findFilePath as i}from"./file-path-fns";import{getWorkspaceRoot as a}from"./get-workspace-root";import{joinPaths as o}from"./join-paths";export async function resolve(r,e={}){const t=e.paths??[];t.length===0&&t.push(process.cwd());const n=a();return t.includes(n)||t.push(n),s(await p(r,{url:t}))}export function resolveSync(r,e={}){const t=e.paths??[];t.length===0&&t.push(process.cwd());const n=a();return t.includes(n)||t.push(n),s(f(r,{url:e.paths}))}export async function resolveSafe(r,e={}){try{return await resolve(r,e)}catch{return}}export function resolveSafeSync(r,e={}){try{return resolveSync(r,e)}catch{return}}export async function importModule(r){const e=await import(r);return e&&c(e)}export async function resolvePackage(r,e={}){let t=await resolveSafe(o(r,"package.json"),e);return t||(t=await resolveSafe(o(r,"index.js"),e),t||(t=await resolveSafe(r,e))),t?i(t):void 0}export function resolvePackageSync(r,e={}){let t=resolveSafeSync(o(r,"package.json"),e);return t||(t=resolveSafeSync(o(r,"index.js"),e),t||(t=resolveSafeSync(r,e))),t?i(t):void 0}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/path",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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": {
|
|
@@ -127,6 +127,20 @@
|
|
|
127
127
|
"default": "./dist/is-root-dir.mjs"
|
|
128
128
|
}
|
|
129
129
|
},
|
|
130
|
+
"./is-parent-path": {
|
|
131
|
+
"import": {
|
|
132
|
+
"types": "./dist/is-parent-path.d.ts",
|
|
133
|
+
"default": "./dist/is-parent-path.mjs"
|
|
134
|
+
},
|
|
135
|
+
"require": {
|
|
136
|
+
"types": "./dist/is-parent-path.d.ts",
|
|
137
|
+
"default": "./dist/is-parent-path.cjs"
|
|
138
|
+
},
|
|
139
|
+
"default": {
|
|
140
|
+
"types": "./dist/is-parent-path.d.ts",
|
|
141
|
+
"default": "./dist/is-parent-path.mjs"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
130
144
|
"./is-file": {
|
|
131
145
|
"import": {
|
|
132
146
|
"types": "./dist/is-file.d.ts",
|
|
@@ -260,5 +274,5 @@
|
|
|
260
274
|
"main": "./dist/index.cjs",
|
|
261
275
|
"module": "./dist/index.mjs",
|
|
262
276
|
"types": "./dist/index.d.ts",
|
|
263
|
-
"gitHead": "
|
|
277
|
+
"gitHead": "366390ec25211fb6b36feed4bf0cffb7713253cb"
|
|
264
278
|
}
|