Skip to content

Commit b9355d2

Browse files
authored
refactor(orval): unify readReExportSpecifiers on RE_EXPORT_LINE (#3778)
Drop the duplicate RE_EXPORT_SPECIFIER (unanchored, global) regex. readReExportSpecifiers now scans line-by-line using RE_EXPORT_LINE, matching how reconcileWorkspaceBarrel classifies lines. Same syntactic shape, one regex owner.
1 parent e30ce3d commit b9355d2

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

packages/orval/src/utils/barrel.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import path from 'node:path';
22
import fs from 'fs-extra';
33

4-
const RE_EXPORT_SPECIFIER = /export\s+\*\s+from\s*['"]([^'"]+)['"]/g;
54
const RE_EXPORT_LINE = /^\s*export\s+\*\s+from\s*['"]([^'"]+)['"]\s*;?\s*$/;
65

76
export function readReExportSpecifiers(content: string): Set<string> {
8-
return new Set([...content.matchAll(RE_EXPORT_SPECIFIER)].map((m) => m[1]));
7+
const specifiers = new Set<string>();
8+
for (const line of content.split(/\r?\n/)) {
9+
const m = line.match(RE_EXPORT_LINE)?.[1];
10+
if (m) specifiers.add(m);
11+
}
12+
return specifiers;
913
}
1014

1115
// Bare specifiers (no leading `.`) are assumed resolvable; the workspace

0 commit comments

Comments
 (0)