@reliverse/pathkit 1.2.3 → 1.2.5

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.
Files changed (2) hide show
  1. package/bin/mod.js +14 -5
  2. package/package.json +1 -1
package/bin/mod.js CHANGED
@@ -14,7 +14,7 @@ const logInternal = (msg) => {
14
14
  console.log(`\x1B[36;2m${message}\x1B[0m`);
15
15
  }
16
16
  };
17
- const DEBUG_MODE = false;
17
+ const DEBUG_MODE = true;
18
18
  const EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".d.ts"];
19
19
  const SLASH = "/";
20
20
  const BACK_SLASH = "\\";
@@ -356,7 +356,9 @@ function reverseResolveAlias(path2, aliases) {
356
356
  }
357
357
  const findAliasMatch = (importPath, paths) => {
358
358
  const firstPathKey = Object.keys(paths)[0];
359
- if (!firstPathKey) return null;
359
+ if (!firstPathKey) {
360
+ return null;
361
+ }
360
362
  const baseAlias = firstPathKey.replace("/*", "");
361
363
  if (importPath.startsWith("@") && !importPath.startsWith(baseAlias)) {
362
364
  return null;
@@ -435,12 +437,15 @@ async function convertStringAliasRelative({
435
437
  const paths = { [pathPattern]: ["./*"] };
436
438
  const importerDir = dirname(importerFile);
437
439
  const match = findAliasMatch(importPath, paths);
438
- if (!match) return importPath;
440
+ if (!match) {
441
+ return importPath;
442
+ }
439
443
  const absPath = resolve(targetDir, match.resolvedPath, match.suffix);
440
444
  const resolvedFile = await resolveFileWithExtensions(absPath);
441
445
  const relPath = toRelativeImport(resolvedFile || absPath, importerDir);
442
446
  const originalExt = extname(importPath);
443
- return getTargetExtension(relPath, originalExt);
447
+ const result = getTargetExtension(relPath, originalExt);
448
+ return result;
444
449
  }
445
450
  function replaceAllInString(original, searchValue, replaceValue) {
446
451
  let currentPosition = 0;
@@ -473,7 +478,9 @@ async function processFile(filePath, aliasToReplace, targetDir, pathExtFilter) {
473
478
  }
474
479
  const importExt = extname(importPath);
475
480
  const shouldProcess = pathExtFilter === "js" && importExt === ".js" || pathExtFilter === "ts" && importExt === ".ts" || pathExtFilter === "none" && importExt === "" || pathExtFilter === "js-ts-none";
476
- if (!shouldProcess) continue;
481
+ if (!shouldProcess) {
482
+ continue;
483
+ }
477
484
  const relPath = await convertStringAliasRelative({
478
485
  importPath,
479
486
  importerFile: filePath,
@@ -486,10 +493,12 @@ async function processFile(filePath, aliasToReplace, targetDir, pathExtFilter) {
486
493
  const searchString = `${originalQuote}${importPath}${originalQuote}`;
487
494
  const replacementString = `${originalQuote}${finalPath}${originalQuote}`;
488
495
  updated = replaceAllInString(updated, searchString, replacementString);
496
+ } else {
489
497
  }
490
498
  }
491
499
  if (content !== updated) {
492
500
  await fs.writeFile(filePath, updated);
501
+ } else {
493
502
  }
494
503
  return changes;
495
504
  }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "license": "MIT",
6
6
  "name": "@reliverse/pathkit",
7
7
  "type": "module",
8
- "version": "1.2.3",
8
+ "version": "1.2.5",
9
9
  "devDependencies": {},
10
10
  "exports": {
11
11
  ".": "./bin/mod.js"