Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/integrations/terminal/ExecaTerminalProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import process from "process"

import type { RooTerminal } from "./types"
import { BaseTerminalProcess } from "./BaseTerminalProcess"
import { getShell } from "../../utils/shell"

export class ExecaTerminalProcess extends BaseTerminalProcess {
private terminalRef: WeakRef<RooTerminal>
Expand Down Expand Up @@ -39,7 +40,7 @@ export class ExecaTerminalProcess extends BaseTerminalProcess {
this.isHot = true

this.subprocess = execa({
shell: true,
shell: getShell(),
cwd: this.terminal.getCurrentWorkingDirectory(),
all: true,
// Ignore stdin to ensure non-interactive mode and prevent hanging
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// npx vitest run integrations/terminal/__tests__/ExecaTerminalProcess.spec.ts

const mockPid = 12345
const mockShell = "/bin/bash"

vitest.mock("execa", () => {
const mockKill = vitest.fn()
Expand All @@ -21,8 +22,13 @@ vitest.mock("ps-tree", () => ({
default: vitest.fn((_: number, cb: any) => cb(null, [])),
}))

vitest.mock("../../../utils/shell", () => ({
getShell: vitest.fn(() => mockShell),
}))

import { execa } from "execa"
import { ExecaTerminalProcess } from "../ExecaTerminalProcess"
import { getShell } from "../../../utils/shell"
import type { RooTerminal } from "../types"

describe("ExecaTerminalProcess", () => {
Expand Down Expand Up @@ -55,13 +61,26 @@ describe("ExecaTerminalProcess", () => {
vitest.clearAllMocks()
})

describe("shell configuration", () => {
it("should use shell from getShell() utility", async () => {
await terminalProcess.run("echo test")
const execaMock = vitest.mocked(execa)
expect(getShell).toHaveBeenCalled()
expect(execaMock).toHaveBeenCalledWith(
expect.objectContaining({
shell: mockShell,
}),
)
})
})

describe("UTF-8 encoding fix", () => {
it("should set LANG and LC_ALL to en_US.UTF-8", async () => {
await terminalProcess.run("echo test")
const execaMock = vitest.mocked(execa)
expect(execaMock).toHaveBeenCalledWith(
expect.objectContaining({
shell: true,
shell: mockShell,
cwd: "/test/cwd",
all: true,
env: expect.objectContaining({
Expand Down
Loading