Archived
fix(terminals): namespace terminal environment marker
This commit is contained in:
@@ -2,4 +2,4 @@
|
|||||||
"@jmfederico/pi-web": patch
|
"@jmfederico/pi-web": patch
|
||||||
---
|
---
|
||||||
|
|
||||||
Set `IS_PIWEB=1` in PI WEB terminal shells.
|
Set `PI_WEB_TERMINAL=1` in PI WEB terminal shells.
|
||||||
|
|||||||
@@ -22,23 +22,23 @@ describe.skipIf(process.platform === "win32")("TerminalService command runs", ()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("IS_PIWEB propagation", () => {
|
describe("PI_WEB_TERMINAL propagation", () => {
|
||||||
let originalIsPiWeb: string | undefined;
|
let originalPiWebTerminal: string | undefined;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
originalIsPiWeb = process.env["IS_PIWEB"];
|
originalPiWebTerminal = process.env["PI_WEB_TERMINAL"];
|
||||||
process.env["IS_PIWEB"] = "conflicting-parent-value";
|
process.env["PI_WEB_TERMINAL"] = "conflicting-parent-value";
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
if (originalIsPiWeb === undefined) {
|
if (originalPiWebTerminal === undefined) {
|
||||||
delete process.env["IS_PIWEB"];
|
delete process.env["PI_WEB_TERMINAL"];
|
||||||
} else {
|
} else {
|
||||||
process.env["IS_PIWEB"] = originalIsPiWeb;
|
process.env["PI_WEB_TERMINAL"] = originalPiWebTerminal;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sets IS_PIWEB for terminal commands", async () => {
|
it("sets PI_WEB_TERMINAL for terminal commands", async () => {
|
||||||
const service = new TerminalService();
|
const service = new TerminalService();
|
||||||
try {
|
try {
|
||||||
const frame = "__PI_WEB_RUN_ENV_7F3A9C__";
|
const frame = "__PI_WEB_RUN_ENV_7F3A9C__";
|
||||||
@@ -48,7 +48,7 @@ describe.skipIf(process.platform === "win32")("TerminalService command runs", ()
|
|||||||
workspaceId: "w1",
|
workspaceId: "w1",
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
title: "Environment check",
|
title: "Environment check",
|
||||||
command: `printf '${frame}%s${frame}\\n' "$IS_PIWEB"`,
|
command: `printf '${frame}%s${frame}\\n' "$PI_WEB_TERMINAL"`,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(await terminalExit(service, run.terminalId)).toContain(`${frame}1${frame}`);
|
expect(await terminalExit(service, run.terminalId)).toContain(`${frame}1${frame}`);
|
||||||
@@ -57,7 +57,7 @@ describe.skipIf(process.platform === "win32")("TerminalService command runs", ()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sets IS_PIWEB in a continued interactive shell", async () => {
|
it("sets PI_WEB_TERMINAL in a continued interactive shell", async () => {
|
||||||
const service = new TerminalService();
|
const service = new TerminalService();
|
||||||
try {
|
try {
|
||||||
const run = service.runCommand({
|
const run = service.runCommand({
|
||||||
@@ -78,7 +78,7 @@ describe.skipIf(process.platform === "win32")("TerminalService command runs", ()
|
|||||||
|
|
||||||
const frame = "__PI_WEB_CONTINUE_ENV_42D8B1__";
|
const frame = "__PI_WEB_CONTINUE_ENV_42D8B1__";
|
||||||
const exit = terminalExit(service, run.terminalId);
|
const exit = terminalExit(service, run.terminalId);
|
||||||
service.write(run.terminalId, `printf '${frame}%s${frame}\\n' "$IS_PIWEB"\nexit\n`);
|
service.write(run.terminalId, `printf '${frame}%s${frame}\\n' "$PI_WEB_TERMINAL"\nexit\n`);
|
||||||
|
|
||||||
const output = await exit;
|
const output = await exit;
|
||||||
expect(output).toContain("[continued in interactive shell]");
|
expect(output).toContain("[continued in interactive shell]");
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ export class TerminalService {
|
|||||||
cwd: record.cwd,
|
cwd: record.cwd,
|
||||||
cols: 100,
|
cols: 100,
|
||||||
rows: 30,
|
rows: 30,
|
||||||
env: { ...process.env, TERM: "xterm-256color", IS_PIWEB: "1" },
|
env: { ...process.env, TERM: "xterm-256color", PI_WEB_TERMINAL: "1" },
|
||||||
});
|
});
|
||||||
this.attachPtyEvents(record);
|
this.attachPtyEvents(record);
|
||||||
const info = toInfo(record);
|
const info = toInfo(record);
|
||||||
@@ -196,7 +196,7 @@ export class TerminalService {
|
|||||||
cwd: options.cwd,
|
cwd: options.cwd,
|
||||||
cols: options.cols ?? 100,
|
cols: options.cols ?? 100,
|
||||||
rows: options.rows ?? 30,
|
rows: options.rows ?? 30,
|
||||||
env: { ...process.env, TERM: "xterm-256color", IS_PIWEB: "1" },
|
env: { ...process.env, TERM: "xterm-256color", PI_WEB_TERMINAL: "1" },
|
||||||
});
|
});
|
||||||
const requestedName = options.name?.trim();
|
const requestedName = options.name?.trim();
|
||||||
const record: TerminalRecord = {
|
const record: TerminalRecord = {
|
||||||
|
|||||||
Reference in New Issue
Block a user