fix(server): apply plugin pty environment (#32296)
This commit is contained in:
@@ -11,6 +11,7 @@ import { CorsConfig, isAllowedRequestOrigin } from "../cors"
|
||||
import { ForbiddenError, PtyNotFoundError } from "../errors"
|
||||
import { PTY_CONNECT_TICKET_QUERY, PTY_CONNECT_TOKEN_HEADER, PTY_CONNECT_TOKEN_HEADER_VALUE } from "../groups/pty"
|
||||
import { response } from "../groups/location"
|
||||
import { PtyEnvironment } from "../pty-environment"
|
||||
|
||||
const ticketScope = Effect.gen(function* () {
|
||||
const location = yield* Location.Service
|
||||
@@ -21,6 +22,7 @@ export const PtyHandler = HttpApiBuilder.group(Api, "server.pty", (handlers) =>
|
||||
Effect.gen(function* () {
|
||||
const tickets = yield* PtyTicket.Service
|
||||
const cors = yield* CorsConfig
|
||||
const environment = yield* PtyEnvironment.Service
|
||||
|
||||
return handlers
|
||||
.handle(
|
||||
@@ -33,11 +35,17 @@ export const PtyHandler = HttpApiBuilder.group(Api, "server.pty", (handlers) =>
|
||||
"pty.create",
|
||||
Effect.fn(function* (ctx) {
|
||||
const pty = yield* Pty.Service
|
||||
const location = yield* Location.Service
|
||||
const cwd = ctx.payload.cwd || location.directory
|
||||
return yield* response(
|
||||
pty.create({
|
||||
...ctx.payload,
|
||||
args: ctx.payload.args ? [...ctx.payload.args] : undefined,
|
||||
env: ctx.payload.env ? { ...ctx.payload.env } : undefined,
|
||||
cwd,
|
||||
env: {
|
||||
...ctx.payload.env,
|
||||
...(yield* environment.get({ directory: location.directory, cwd })),
|
||||
},
|
||||
}),
|
||||
)
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user