@reliverse/pathkit 1.1.2 → 1.1.4
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/README.md +1 -1
- package/bin/mod.js +8 -14
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
- ⚙️ **node.js api compatible** – familiar methods, no learning curve
|
|
13
13
|
- 🚀 **modern & fast** – typescript, pure esm, bun & node‑ready
|
|
14
14
|
- 🧠 **predictable & testable** – deterministic output across windows / macos / linux
|
|
15
|
-
- 🧼 **no dependencies** – just better path api + couple of cool utilities = [
|
|
15
|
+
- 🧼 **no dependencies** – just better path api + couple of cool utilities = [5kB](https://bundlephobia.com/package/@reliverse/pathkit@latest)
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
package/bin/mod.js
CHANGED
|
@@ -14,7 +14,7 @@ const UNC_REGEX = /^[/\\]{2}/;
|
|
|
14
14
|
const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
15
15
|
const ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
16
16
|
const PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
|
|
17
|
-
const IMPORT_REGEX = /(?:import\s+(?:[\s\S]*?)\s+from\s+|import\s*\(\s*)\s*(['"])(
|
|
17
|
+
const IMPORT_REGEX = /(?:import\s+(?:[\s\S]*?)\s+from\s+|import\s*\(\s*)\s*(['"])([^'"]+)\1/g;
|
|
18
18
|
async function cleanDirs(dirs) {
|
|
19
19
|
await Promise.all(
|
|
20
20
|
dirs.map(async (d) => {
|
|
@@ -438,13 +438,9 @@ async function resolveFileWithExtensions(basePath, extensions = ["", ...EXTENSIO
|
|
|
438
438
|
return null;
|
|
439
439
|
}
|
|
440
440
|
function getTargetExtension(relPath, originalExt) {
|
|
441
|
-
const foundExt = extname(relPath);
|
|
442
441
|
if (originalExt) {
|
|
443
442
|
return relPath;
|
|
444
443
|
}
|
|
445
|
-
if (foundExt) {
|
|
446
|
-
return relPath.slice(0, -foundExt.length);
|
|
447
|
-
}
|
|
448
444
|
return relPath;
|
|
449
445
|
}
|
|
450
446
|
async function convertStringAliasRelative({
|
|
@@ -492,10 +488,7 @@ async function processFile(filePath, aliasToReplace, targetDir, pathExtFilter) {
|
|
|
492
488
|
for (const match of matches) {
|
|
493
489
|
const originalQuote = match[1];
|
|
494
490
|
const importPath = match[2];
|
|
495
|
-
if (!importPath.startsWith(baseAlias)
|
|
496
|
-
continue;
|
|
497
|
-
}
|
|
498
|
-
if (importPath.startsWith("@") && !importPath.startsWith(baseAlias)) {
|
|
491
|
+
if (!importPath.startsWith(baseAlias)) {
|
|
499
492
|
continue;
|
|
500
493
|
}
|
|
501
494
|
const importExt = extname(importPath);
|
|
@@ -507,10 +500,11 @@ async function processFile(filePath, aliasToReplace, targetDir, pathExtFilter) {
|
|
|
507
500
|
pathPattern: normalizedAlias,
|
|
508
501
|
targetDir
|
|
509
502
|
});
|
|
510
|
-
|
|
511
|
-
|
|
503
|
+
const finalPath = pathExtFilter === "none" ? relPath.replace(/\.(ts|js|tsx|jsx|mjs|cjs)$/, "") : relPath;
|
|
504
|
+
if (importPath !== finalPath) {
|
|
505
|
+
changes.push({ from: importPath, to: finalPath });
|
|
512
506
|
const searchString = `${originalQuote}${importPath}${originalQuote}`;
|
|
513
|
-
const replacementString = `${originalQuote}${
|
|
507
|
+
const replacementString = `${originalQuote}${finalPath}${originalQuote}`;
|
|
514
508
|
updated = replaceAllInString(updated, searchString, replacementString);
|
|
515
509
|
}
|
|
516
510
|
}
|
|
@@ -778,8 +772,8 @@ async function stripPathSegmentsInDirectory({
|
|
|
778
772
|
logInternal(` - skipping non-path import: ${importPath}`);
|
|
779
773
|
continue;
|
|
780
774
|
}
|
|
781
|
-
if (
|
|
782
|
-
logInternal(` - skipping
|
|
775
|
+
if (alias && !importPath.startsWith(alias.replace("/*", ""))) {
|
|
776
|
+
logInternal(` - skipping non-alias import: ${importPath}`);
|
|
783
777
|
continue;
|
|
784
778
|
}
|
|
785
779
|
logInternal(` Processing import: ${importPath}`);
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"name": "@reliverse/pathkit",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"version": "1.1.
|
|
8
|
+
"version": "1.1.4",
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@biomejs/biome": "1.9.4",
|
|
11
11
|
"@eslint/js": "^9.27.0",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"@reliverse/relinka": "^1.4.5",
|
|
15
15
|
"@reliverse/rematch": "^1.1.0",
|
|
16
16
|
"@stylistic/eslint-plugin": "^4.2.0",
|
|
17
|
-
"@types/bun": "^1.2.
|
|
17
|
+
"@types/bun": "^1.2.14",
|
|
18
18
|
"@types/node": "^22.15.21",
|
|
19
19
|
"eslint": "^9.27.0",
|
|
20
20
|
"eslint-plugin-no-relative-import-paths": "^1.6.1",
|
|
21
21
|
"eslint-plugin-perfectionist": "^4.13.0",
|
|
22
|
-
"knip": "^5.57.
|
|
22
|
+
"knip": "^5.57.2",
|
|
23
23
|
"magic-string": "^0.30.17",
|
|
24
24
|
"p-map": "^7.0.3",
|
|
25
25
|
"typescript": "^5.8.3",
|