diff --git a/.changeset/add-pi-web-terminal-environment.md b/.changeset/add-pi-web-terminal-environment.md new file mode 100644 index 0000000..5fd24f2 --- /dev/null +++ b/.changeset/add-pi-web-terminal-environment.md @@ -0,0 +1,5 @@ +--- +"@jmfederico/pi-web": patch +--- + +Set `IS_PIWEB=1` in PI WEB terminal shells. diff --git a/package.json b/package.json index e84997d..67a68f9 100644 --- a/package.json +++ b/package.json @@ -140,5 +140,8 @@ "./extensions" ], "image": "https://raw.githubusercontent.com/jmfederico/pi-web/main/docs/assets/pi-web-banner.png" + }, + "allowScripts": { + "node-pty@1.1.0": true } } diff --git a/src/server/terminals/terminalService.test.ts b/src/server/terminals/terminalService.test.ts index 0b55d1a..3b314cf 100644 --- a/src/server/terminals/terminalService.test.ts +++ b/src/server/terminals/terminalService.test.ts @@ -22,6 +22,24 @@ describe.skipIf(process.platform === "win32")("TerminalService command runs", () } }); + it("sets IS_PIWEB for terminal commands", async () => { + const service = new TerminalService(); + try { + const run = service.runCommand({ + origin: "core", + projectId: "p1", + workspaceId: "w1", + cwd: process.cwd(), + title: "Environment check", + command: "printf '%s' \"$IS_PIWEB\"", + }); + + expect(await terminalExit(service, run.terminalId)).toContain("1"); + } finally { + service.dispose(); + } + }); + it("tracks dedicated terminal command runs through completion", async () => { const service = new TerminalService(); try { diff --git a/src/server/terminals/terminalService.ts b/src/server/terminals/terminalService.ts index 63204ff..db26e34 100644 --- a/src/server/terminals/terminalService.ts +++ b/src/server/terminals/terminalService.ts @@ -163,7 +163,7 @@ export class TerminalService { cwd: record.cwd, cols: 100, rows: 30, - env: { ...process.env, TERM: "xterm-256color" }, + env: { ...process.env, TERM: "xterm-256color", IS_PIWEB: "1" }, }); this.attachPtyEvents(record); const info = toInfo(record); @@ -196,7 +196,7 @@ export class TerminalService { cwd: options.cwd, cols: options.cols ?? 100, rows: options.rows ?? 30, - env: { ...process.env, TERM: "xterm-256color" }, + env: { ...process.env, TERM: "xterm-256color", IS_PIWEB: "1" }, }); const requestedName = options.name?.trim(); const record: TerminalRecord = {