mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
refactor(repl): use bun.path.join for history path construction
Replace std.fs.path.join with bun.path.join for cross-platform path construction as suggested in code review. The bun.path helper provides consistent path handling across platforms. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1411,8 +1411,11 @@ pub const History = struct {
|
||||
// Try to get home directory from environment
|
||||
const home = bun.getenvZ("HOME") orelse bun.getenvZ("USERPROFILE") orelse return null;
|
||||
|
||||
// Build path: $HOME/.bun_repl_history using proper path joining for cross-platform support
|
||||
const path = std.fs.path.join(self.allocator, &.{ home, HISTORY_FILE_NAME }) catch return null;
|
||||
// Build path: $HOME/.bun_repl_history using Bun's path helper for cross-platform support
|
||||
// bun.path.join returns a slice into a thread-local buffer, so we need to dupe it
|
||||
const parts = [_][]const u8{ home, HISTORY_FILE_NAME };
|
||||
const joined = bun.path.join(&parts, .auto);
|
||||
const path = self.allocator.dupe(u8, joined) catch return null;
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user