mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
fix: normalize path separators in check-entry-graphs on Windows (#11399)
`scripts/check-entry-graphs.mjs` built the list of files each export
reaches with `path.relative()`, which returns paths with `\` separators
on Windows. The allow and forbid patterns are written with `/`, which
caused two problems on Windows:
- The allow entry `packages/telemetry/src/index.ts` never matched, so
the bare `index.ts` forbid pattern flagged it and the check failed even
though nothing was wrong.
- Forbid patterns that contain a `/` (`providers/`, `runtime/host.ts`,
...) never matched, so real violations went unreported.
The fix converts the relative paths to `/` before any comparison. On
Linux and macOS nothing changes.
Testing:
- The scripts have no unit tests, so no test was added.
- `node scripts/check-entry-graphs.mjs` and `npm run check` pass on
Linux.
- I simulated Windows path handling with `path.win32`, without running
Windows itself:
- Before the fix: `relative(...)` gives
`packages\telemetry\src\index.ts`, and
`endsWith("packages/telemetry/src/index.ts")` is false.
- After the fix: the path becomes `packages/telemetry/src/index.ts`, and
the suffix check is true.
Fixes #11333
Requested by @badlogic
Co-authored-by: triagent <triagent@localhost>
This commit is contained in:
parent
984cf6643d
commit
0eea54f11c
1 changed files with 2 additions and 2 deletions
|
|
@ -12,7 +12,7 @@
|
|||
*/
|
||||
|
||||
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
||||
import { dirname, relative, resolve } from "node:path";
|
||||
import { dirname, relative, resolve, sep } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
|
|
@ -153,7 +153,7 @@ for (const [pkgDir, budgets] of Object.entries(BUDGETS)) {
|
|||
failures += 1;
|
||||
continue;
|
||||
}
|
||||
const graph = [...walk(source)].map((file) => relative(ROOT, file));
|
||||
const graph = [...walk(source)].map((file) => relative(ROOT, file).split(sep).join("/"));
|
||||
if (graph.length > budget.maxFiles) {
|
||||
console.error(
|
||||
`${pkgDir} export "${name}" reaches ${graph.length} files, budget ${budget.maxFiles}\n` +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue