@stryke/path 0.18.1 → 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 +1 -1
- package/dist/append.mjs +1 -1
- package/dist/correct-path.spec.cjs +12 -0
- package/dist/correct-path.spec.d.ts +1 -0
- package/dist/correct-path.spec.mjs +1 -0
- package/dist/is-parent-path.cjs +4 -4
- package/dist/is-parent-path.mjs +1 -1
- package/dist/replace.cjs +4 -4
- package/dist/replace.mjs +1 -1
- package/dist/slash.cjs +6 -0
- package/dist/slash.d.ts +7 -0
- package/dist/slash.mjs +1 -1
- package/package.json +16 -2
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.
|
|
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
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _correctPath = require("./correct-path.cjs");
|
|
4
|
+
describe("stripStars", () => {
|
|
5
|
+
it("stripStars - single star", () => {
|
|
6
|
+
const t = (0, _correctPath.stripStars)("hello/*");
|
|
7
|
+
expect(t).toBe("hello");
|
|
8
|
+
}), it("stripStars - multiple stars", () => {
|
|
9
|
+
const t = (0, _correctPath.stripStars)("hello/**/*");
|
|
10
|
+
expect(t).toBe("hello");
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{stripStars as s}from"./correct-path";describe("stripStars",()=>{it("stripStars - single star",()=>{const t=s("hello/*");expect(t).toBe("hello")}),it("stripStars - multiple stars",()=>{const t=s("hello/**/*");expect(t).toBe("hello")})});
|
package/dist/is-parent-path.cjs
CHANGED
|
@@ -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(
|
|
9
|
-
const r = (0, _slash.
|
|
10
|
-
|
|
11
|
-
return r !==
|
|
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
|
}
|
package/dist/is-parent-path.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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,
|
|
14
|
-
return (0, _correctPath.correctPath)((0, _isParentPath.isParentPath)(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,
|
|
17
|
-
return (0, _correctPath.correctPath)(r.replace(!
|
|
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
|
|
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.
|
|
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": {
|
|
@@ -239,6 +239,20 @@
|
|
|
239
239
|
"default": "./dist/correct-path.mjs"
|
|
240
240
|
}
|
|
241
241
|
},
|
|
242
|
+
"./correct-path.spec": {
|
|
243
|
+
"import": {
|
|
244
|
+
"types": "./dist/correct-path.spec.d.ts",
|
|
245
|
+
"default": "./dist/correct-path.spec.mjs"
|
|
246
|
+
},
|
|
247
|
+
"require": {
|
|
248
|
+
"types": "./dist/correct-path.spec.d.ts",
|
|
249
|
+
"default": "./dist/correct-path.spec.cjs"
|
|
250
|
+
},
|
|
251
|
+
"default": {
|
|
252
|
+
"types": "./dist/correct-path.spec.d.ts",
|
|
253
|
+
"default": "./dist/correct-path.spec.mjs"
|
|
254
|
+
}
|
|
255
|
+
},
|
|
242
256
|
"./asset-extensions": {
|
|
243
257
|
"import": {
|
|
244
258
|
"types": "./dist/asset-extensions.d.ts",
|
|
@@ -280,5 +294,5 @@
|
|
|
280
294
|
"main": "./dist/index.cjs",
|
|
281
295
|
"module": "./dist/index.mjs",
|
|
282
296
|
"types": "./dist/index.d.ts",
|
|
283
|
-
"gitHead": "
|
|
297
|
+
"gitHead": "318f947b4a5068b62181d287cfa768f711d2e95e"
|
|
284
298
|
}
|