From 0772423d1a9f23c3f15b9642dbcca6800ac9cc77 Mon Sep 17 00:00:00 2001 From: Divyanshi Singh Date: Thu, 3 Sep 2026 01:03:53 +0530 Subject: [PATCH] fix: normalize paths in Windows tests --- packages/core/src/generators/ast/generate.mjs | 4 ++-- packages/react/src/html/utils/copying.mjs | 2 +- scripts/comparators/file-size.mjs | 3 +-- scripts/comparators/object-assertion.mjs | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/core/src/generators/ast/generate.mjs b/packages/core/src/generators/ast/generate.mjs index 81ef3f4ca..28ce71c4f 100644 --- a/packages/core/src/generators/ast/generate.mjs +++ b/packages/core/src/generators/ast/generate.mjs @@ -1,7 +1,7 @@ 'use strict'; import { readFile } from 'node:fs/promises'; -import { relative, sep } from 'node:path/posix'; +import { relative, sep } from 'node:path'; import globParent from 'glob-parent'; import { globSync } from 'tinyglobby'; @@ -65,7 +65,7 @@ export async function processChunk(inputSlice, itemIndices) { ); // The path is the relative path minus the extension - const relativePath = sep + withExt(relative(parent, path)); + const relativePath = `/${withExt(relative(parent, path)).replaceAll(sep, '/')}`; let tree; diff --git a/packages/react/src/html/utils/copying.mjs b/packages/react/src/html/utils/copying.mjs index e9500552c..ea0125e98 100644 --- a/packages/react/src/html/utils/copying.mjs +++ b/packages/react/src/html/utils/copying.mjs @@ -28,7 +28,7 @@ export async function copyStaticAssets(config) { } catch (err) { if (err.code !== 'ENOENT') { logger.error( - `[html-generator] Failed to copy asset from ${src} to ${dest}: ${err.message}` + `[html-generator] Failed to copy asset from ${src} to ${dest.replaceAll('\\', '/')}: ${err.message}` ); } } diff --git a/scripts/comparators/file-size.mjs b/scripts/comparators/file-size.mjs index 81e2e8653..43b32366e 100644 --- a/scripts/comparators/file-size.mjs +++ b/scripts/comparators/file-size.mjs @@ -65,9 +65,8 @@ if (changed.length) { base === 0 ? '' : ` (${sign}${((diff / base) * 100).toFixed(1)}%)`; const diffFormatted = `${sign}${formatBytes(diff)}${percent}`; - return `| \`${file}\` | ${baseStats.has(file) ? formatBytes(base) : '—'} | ${headStats.has(file) ? formatBytes(head) : '—'} | ${diffFormatted} |`; + return `| \`${file.replace(/\\/g, '/')}\` | ${baseStats.has(file) ? formatBytes(base) : '—'} | ${headStats.has(file) ? formatBytes(head) : '—'} | ${diffFormatted} |`; }); - sections.push( [ `**Output size:** ${changed.length} ${changed.length === 1 ? 'file' : 'files'} changed · net ${totalSign}${formatBytes(totalDiff)}`, diff --git a/scripts/comparators/object-assertion.mjs b/scripts/comparators/object-assertion.mjs index 33408523d..7920395b5 100644 --- a/scripts/comparators/object-assertion.mjs +++ b/scripts/comparators/object-assertion.mjs @@ -18,11 +18,11 @@ export const details = (summary, diff) => const getFileDiff = async file => { if (!baseFileSet.has(file)) { - return `- \`${file}\` added`; + return `- \`${file.replace(/\\/g, '/')}\` added`; } if (!headFileSet.has(file)) { - return `- \`${file}\` removed`; + return `- \`${file.replace(/\\/g, '/')}\` removed`; } const basePath = join(BASE, file);