@reliverse/pathkit 1.2.7 → 1.2.8

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/bin/mod.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { PlatformPath } from "node:path";
2
2
  import { getFileImportsExports, type ImportExportInfo, type ImportExportSpecifier, type GetFileImportsExportsOptions } from "./impl/getFileImportsExports.js";
3
3
  declare const normalizedAliasSymbol: unique symbol;
4
+ export declare const IMPORT_EXPORT_REGEX: RegExp;
4
5
  interface NormalizedRecord extends Record<string, string> {
5
6
  [normalizedAliasSymbol]?: true;
6
7
  }
package/bin/mod.js CHANGED
@@ -30,7 +30,7 @@ const UNC_REGEX = /^[/\\]{2}/;
30
30
  const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
31
31
  const ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
32
32
  const PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
33
- const IMPORT_REGEX = /(?:import\s+(?:[\s\S]*?)\s+from\s+|import\s*\(\s*)\s*(['"])([^'"]+)\1/g;
33
+ export const IMPORT_EXPORT_REGEX = /(?:import\s+(?:type\s+)?[\s\S]*?\s+from\s+|import\s*\(\s*|export\s+(?:type\s+)?(?:\*\s+from\s+|(?:\w+(?:\s*,\s*|\s+))?\{[\s\S]*?\}(?:\s*,\s*\w+)?\s+from\s+|\w+\s+from\s+))\s*(['"])([^'"]+)\1/g;
34
34
  function normalizeWindowsPath(input = "") {
35
35
  if (!input) return input;
36
36
  return input.replace(/\\/g, SLASH).replace(DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
@@ -470,13 +470,13 @@ async function processFile(filePath, aliasToReplace, targetDir, pathExtFilter, d
470
470
  const content = await fs.readFile(filePath, "utf-8");
471
471
  let updated = content;
472
472
  const changes = [];
473
- const matches = Array.from(content.matchAll(IMPORT_REGEX));
473
+ const matches = Array.from(content.matchAll(IMPORT_EXPORT_REGEX));
474
474
  const normalizedAlias = aliasToReplace.endsWith("/*") ? aliasToReplace : `${aliasToReplace}/*`;
475
475
  const baseAlias = aliasToReplace.replace("/*", "");
476
476
  log(`[processFile] Processing file: ${filePath}`);
477
477
  log(` - normalizedAlias: ${normalizedAlias}`);
478
478
  log(` - baseAlias: ${baseAlias}`);
479
- log(` - found ${matches.length} import statements`);
479
+ log(` - found ${matches.length} import/export statements`);
480
480
  for (const match of matches) {
481
481
  const originalQuote = match[1];
482
482
  const importPath = match[2];
@@ -787,7 +787,7 @@ async function stripPathSegmentsInDirectory({
787
787
  const content = await fs.readFile(fullPath, "utf-8");
788
788
  let updated = content;
789
789
  const changes = [];
790
- const matches = Array.from(content.matchAll(IMPORT_REGEX));
790
+ const matches = Array.from(content.matchAll(IMPORT_EXPORT_REGEX));
791
791
  for (const match of matches) {
792
792
  const originalQuote = match[1];
793
793
  const importPath = match[2];
@@ -902,7 +902,7 @@ async function attachPathSegmentsInDirectory({
902
902
  const content = await fs.readFile(fullPath, "utf-8");
903
903
  let updated = content;
904
904
  const changes = [];
905
- const matches = Array.from(content.matchAll(IMPORT_REGEX));
905
+ const matches = Array.from(content.matchAll(IMPORT_EXPORT_REGEX));
906
906
  for (const match of matches) {
907
907
  const originalQuote = match[1];
908
908
  const importPath = match[2];
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.7",
8
+ "version": "1.2.8",
9
9
  "devDependencies": {},
10
10
  "exports": {
11
11
  ".": "./bin/mod.js"