Skip to content
Merged
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
34 changes: 34 additions & 0 deletions packages/hub/src/node/__tests__/host-terminals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,40 @@ describe('devframeTerminalHost child-process status lifecycle', () => {
})

describe('devframeTerminalHost interactive PTY sessions', () => {
itPty('inherits the parent process environment', async () => {
expect.assertions(1)

const environmentVariable = 'DEVFRAME_PTY_INHERITED_ENV'
const previousValue = process.env[environmentVariable]
process.env[environmentVariable] = 'inherited'

let session: Awaited<ReturnType<DevframeTerminalsHost['startPtySession']>> | undefined
try {
const { host, sinks } = createTerminalHost()
session = await host.startPtySession({
command: NODE,
args: ['-e', `process.stdout.write(process.env.${environmentVariable} ?? "missing")`],
}, {
id: 'pty-environment',
title: 'PTY environment',
})

await waitUntil(() => {
if (!sinks.get('pty-environment')?.closed)
throw new Error('PTY stream is still open')
})

expect(session.buffer?.join('')).toContain('inherited')
}
finally {
await session?.terminate()
if (previousValue === undefined)
delete process.env[environmentVariable]
else
process.env[environmentVariable] = previousValue
}
})

itPosixPty('spawns an interactive PTY that accepts input and is marked interactive', async () => {
const { host, sinks } = createTerminalHost()

Expand Down
1 change: 1 addition & 0 deletions packages/hub/src/node/host-terminals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ export class DevframeTerminalsHost implements DevframeTerminalsHostType {
rows,
cwd: executeOptions.cwd ?? process.cwd(),
env: {
...process.env,
TERM: PTY_TERM_NAME,
COLORTERM: 'truecolor',
FORCE_COLOR: '1',
Expand Down
Loading