Skip to content

Commit 509c32a

Browse files
committed
refactor: remove speculative Windows short-path resolution
The CI failure was caused by separator mismatch (mixed vs all-forward-slash), not by 8.3 short name mismatch. Remove the resolveWindowsLongPath function and related test since the forward-slash fix already handles the issue.
1 parent 5bc2b0e commit 509c32a

File tree

2 files changed

+0
-43
lines changed

2 files changed

+0
-43
lines changed

packages/tools/src/__tests__/utils.spec.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -152,22 +152,6 @@ Done in 171ms using pnpm v10.16.1
152152
});
153153
});
154154

155-
test.skipIf(process.platform !== 'win32')(
156-
'Windows: resolve short path names (8.3) when replacing cwd',
157-
() => {
158-
// On Windows CI, tmpdir() may return short names like RUNNER~1.
159-
// fs.realpathSync.native() resolves them to long names.
160-
// Both forms should be replaced with <cwd>.
161-
const fs = require('node:fs');
162-
const shortCwd = fs.realpathSync(require('node:os').tmpdir());
163-
const longCwd = fs.realpathSync.native(require('node:os').tmpdir());
164-
if (shortCwd !== longCwd) {
165-
const output = ` RUN ${longCwd}\n`;
166-
expect(replaceUnstableOutput(output, shortCwd)).toBe(' RUN <cwd>\n');
167-
}
168-
},
169-
);
170-
171155
test('replace tsdown output', () => {
172156
const output = `
173157
ℹ tsdown v0.15.1 powered by rolldown v0.15.1

packages/tools/src/utils.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import fs from 'node:fs';
21
import { homedir } from 'node:os';
32
import path from 'node:path';
43

@@ -9,22 +8,6 @@ const ANSI_ESCAPE_REGEX = new RegExp(
98
'g',
109
);
1110

12-
/**
13-
* On Windows, resolve 8.3 short path names (e.g., RUNNER~1) to long names.
14-
* Uses fs.realpathSync.native() which calls the OS-level realpath and resolves
15-
* short names. Falls back to the original path if it doesn't exist.
16-
*/
17-
function resolveWindowsLongPath(p: string): string {
18-
if (process.platform !== 'win32') {
19-
return p;
20-
}
21-
try {
22-
return fs.realpathSync.native(p);
23-
} catch {
24-
return p;
25-
}
26-
}
27-
2811
export function replaceUnstableOutput(output: string, cwd?: string) {
2912
// Normalize line endings and strip ANSI escapes so snapshots are stable
3013
// across CI platforms and terminal capabilities.
@@ -46,19 +29,9 @@ export function replaceUnstableOutput(output: string, cwd?: string) {
4629
output = output.replaceAll(rawPath, placeholder);
4730
};
4831
replacePathToken(cwd, '<cwd>');
49-
// On Windows, also try the long-path form to handle 8.3 short name mismatches
50-
// (e.g., cwd has RUNNER~1 but output has runneradmin, or vice versa).
51-
const longCwd = resolveWindowsLongPath(cwd);
52-
if (longCwd !== cwd) {
53-
replacePathToken(longCwd, '<cwd>');
54-
}
5532
const parent = path.dirname(cwd);
5633
if (parent !== '/') {
5734
replacePathToken(parent, '<cwd>/..');
58-
const longParent = resolveWindowsLongPath(parent);
59-
if (longParent !== parent) {
60-
replacePathToken(longParent, '<cwd>/..');
61-
}
6235
}
6336
}
6437
// On Windows, normalize path separators in file paths for consistent snapshots.

0 commit comments

Comments
 (0)