fix: address additional review feedback for built-in REPL

- Use cross-platform PID: std.c.getpid() on POSIX, GetCurrentProcessId() on Windows
- Resolve .load command paths relative to process.cwd()
- Remove empty placeholder test file

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Claude Bot
2026-01-14 07:49:59 +00:00
parent ea511ed08c
commit 768b60ebf1
3 changed files with 7 additions and 12 deletions

View File

@@ -9,7 +9,10 @@ pub const ReplCommand = struct {
const temp_dir = bun.fs.FileSystem.RealFS.platformTempDir();
// Create unique temp file name with PID to avoid collisions
const pid = std.os.linux.getpid();
const pid = if (bun.Environment.isWindows)
std.os.windows.GetCurrentProcessId()
else
std.c.getpid();
var temp_path_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
const temp_path = std.fmt.bufPrint(&temp_path_buf, "{s}/bun-repl-{d}.ts", .{ temp_dir, pid }) catch {
Output.prettyErrorln("<r><red>error<r>: Could not create temp path", .{});

View File

@@ -192,7 +192,9 @@ const replCommands: Record<string, { help: string; action: (args: string) => voi
return;
}
try {
const code = fs.readFileSync(filename.trim(), "utf-8");
// Resolve relative paths against the user's current working directory
const resolvedPath = path.resolve(process.cwd(), filename.trim());
const code = fs.readFileSync(resolvedPath, "utf-8");
const result = evaluateCode(code);
if (result !== undefined) {
console.log(formatResult(result));

View File

@@ -1,10 +0,0 @@
// Tests for `bun repl` functionality are in test/regression/issue/26058.test.ts
// This file is kept for backwards compatibility but the main tests are in the regression folder
import { describe, test } from "bun:test";
describe("bun repl", () => {
test.skip("moved to test/regression/issue/26058.test.ts", () => {
// REPL tests have been consolidated in the regression test file
});
});