authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-05 00:18:54-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-05 00:18:54-07:00
logda1bebbb11701b58ebdde5ee019f3aeef3d42b27
treeb454af0efdf4c49d05bb6a22aa9094ce301042d1
parentc6410d37d7ff1bdb65b38f0e9c30da392a4de804
signature Signed by PGP key B5690EEEBB952194

refactor(shared): remove retired PATH capture parser (#9991)


2 files changed, 0 insertions(+), 37 deletions(-)

packages/shared/src/shell.test.ts-23
...@@ -8,7 +8,6 @@ import * as TestClock from "effect/testing/TestClock";...@@ -8,7 +8,6 @@ import * as TestClock from "effect/testing/TestClock";
8import { describe, expect, it, vi } from "vite-plus/test";8import { describe, expect, it, vi } from "vite-plus/test";
99
10import {10import {
11 extractPathFromShellOutput,
12 CommandAvailability,11 CommandAvailability,
13 CommandResolutionCache,12 CommandResolutionCache,
14 type CommandAvailabilityChecker,13 type CommandAvailabilityChecker,
...@@ -39,28 +38,6 @@ const withWindowsEnvironmentMocks = <A, E, R>(...@@ -39,28 +38,6 @@ const withWindowsEnvironmentMocks = <A, E, R>(
39 Effect.provideService(CommandAvailability, commandAvailable),38 Effect.provideService(CommandAvailability, commandAvailable),
40 );39 );
4140
42describe("extractPathFromShellOutput", () => {
43 it("extracts the path between capture markers", () => {
44 expect(
45 extractPathFromShellOutput(
46 "__T3CODE_PATH_START__\n/opt/homebrew/bin:/usr/bin\n__T3CODE_PATH_END__\n",
47 ),
48 ).toBe("/opt/homebrew/bin:/usr/bin");
49 });
50
51 it("ignores shell startup noise around the capture markers", () => {
52 expect(
53 extractPathFromShellOutput(
54 "Welcome to fish\n__T3CODE_PATH_START__\n/opt/homebrew/bin:/usr/bin\n__T3CODE_PATH_END__\nBye\n",
55 ),
56 ).toBe("/opt/homebrew/bin:/usr/bin");
57 });
58
59 it("returns null when the markers are missing", () => {
60 expect(extractPathFromShellOutput("/opt/homebrew/bin /usr/bin")).toBeNull();
61 });
62});
63
64describe("readPathFromLoginShell", () => {41describe("readPathFromLoginShell", () => {
65 it("uses a shell-agnostic printenv PATH probe", () => {42 it("uses a shell-agnostic printenv PATH probe", () => {
66 const execFile = vi.fn<43 const execFile = vi.fn<
packages/shared/src/shell.ts-14
...@@ -12,8 +12,6 @@ import * as Path from "effect/Path";...@@ -12,8 +12,6 @@ import * as Path from "effect/Path";
12import { HostProcessEnvironment, HostProcessPlatform } from "./hostProcess.ts";12import { HostProcessEnvironment, HostProcessPlatform } from "./hostProcess.ts";
13import * as Context from "effect/Context";13import * as Context from "effect/Context";
1414
15const PATH_CAPTURE_START = "__T3CODE_PATH_START__";
16const PATH_CAPTURE_END = "__T3CODE_PATH_END__";
17const SHELL_ENV_NAME_PATTERN = /^[A-Z0-9_]+$/;15const SHELL_ENV_NAME_PATTERN = /^[A-Z0-9_]+$/;
18const WINDOWS_PATH_DELIMITER = ";";16const WINDOWS_PATH_DELIMITER = ";";
19const POSIX_PATH_DELIMITER = ":";17const POSIX_PATH_DELIMITER = ":";
...@@ -179,18 +177,6 @@ export function listLoginShellCandidates(...@@ -179,18 +177,6 @@ export function listLoginShellCandidates(
179 return candidates;177 return candidates;
180}178}
181179
182export function extractPathFromShellOutput(output: string): string | null {
183 const startIndex = output.indexOf(PATH_CAPTURE_START);
184 if (startIndex === -1) return null;
185
186 const valueStartIndex = startIndex + PATH_CAPTURE_START.length;
187 const endIndex = output.indexOf(PATH_CAPTURE_END, valueStartIndex);
188 if (endIndex === -1) return null;
189
190 const pathValue = output.slice(valueStartIndex, endIndex).trim();
191 return pathValue.length > 0 ? pathValue : null;
192}
193
194export function readPathFromLoginShell(180export function readPathFromLoginShell(
195 shell: string,181 shell: string,
196 execFile: ExecFileSyncLike = NodeChildProcess.execFileSync,182 execFile: ExecFileSyncLike = NodeChildProcess.execFileSync,