mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
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:
@@ -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", .{});
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user