refactor(shared): remove retired PATH capture parser (#9991)
This commit is contained in:
1 parent
c6410d37d7
commit
da1bebbb11
2 files changed
-37
No files matched your search
@@ -8,7 +8,6 @@ import * as TestClock from "effect/testing/TestClock";
|
||||
import { describe, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
extractPathFromShellOutput,
|
||||
CommandAvailability,
|
||||
CommandResolutionCache,
|
||||
type CommandAvailabilityChecker,
|
||||
@@ -39,28 +38,6 @@ const withWindowsEnvironmentMocks = <A, E, R>(
|
||||
Effect.provideService(CommandAvailability, commandAvailable),
|
||||
);
|
||||
|
||||
describe("extractPathFromShellOutput", () => {
|
||||
it("extracts the path between capture markers", () => {
|
||||
expect(
|
||||
extractPathFromShellOutput(
|
||||
"__T3CODE_PATH_START__\n/opt/homebrew/bin:/usr/bin\n__T3CODE_PATH_END__\n",
|
||||
),
|
||||
).toBe("/opt/homebrew/bin:/usr/bin");
|
||||
});
|
||||
|
||||
it("ignores shell startup noise around the capture markers", () => {
|
||||
expect(
|
||||
extractPathFromShellOutput(
|
||||
"Welcome to fish\n__T3CODE_PATH_START__\n/opt/homebrew/bin:/usr/bin\n__T3CODE_PATH_END__\nBye\n",
|
||||
),
|
||||
).toBe("/opt/homebrew/bin:/usr/bin");
|
||||
});
|
||||
|
||||
it("returns null when the markers are missing", () => {
|
||||
expect(extractPathFromShellOutput("/opt/homebrew/bin /usr/bin")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("readPathFromLoginShell", () => {
|
||||
it("uses a shell-agnostic printenv PATH probe", () => {
|
||||
const execFile = vi.fn<
|
||||
|
||||
@@ -12,8 +12,6 @@ import * as Path from "effect/Path";
|
||||
import { HostProcessEnvironment, HostProcessPlatform } from "./hostProcess.ts";
|
||||
import * as Context from "effect/Context";
|
||||
|
||||
const PATH_CAPTURE_START = "__T3CODE_PATH_START__";
|
||||
const PATH_CAPTURE_END = "__T3CODE_PATH_END__";
|
||||
const SHELL_ENV_NAME_PATTERN = /^[A-Z0-9_]+$/;
|
||||
const WINDOWS_PATH_DELIMITER = ";";
|
||||
const POSIX_PATH_DELIMITER = ":";
|
||||
@@ -179,18 +177,6 @@ export function listLoginShellCandidates(
|
||||
return candidates;
|
||||
}
|
||||
|
||||
export function extractPathFromShellOutput(output: string): string | null {
|
||||
const startIndex = output.indexOf(PATH_CAPTURE_START);
|
||||
if (startIndex === -1) return null;
|
||||
|
||||
const valueStartIndex = startIndex + PATH_CAPTURE_START.length;
|
||||
const endIndex = output.indexOf(PATH_CAPTURE_END, valueStartIndex);
|
||||
if (endIndex === -1) return null;
|
||||
|
||||
const pathValue = output.slice(valueStartIndex, endIndex).trim();
|
||||
return pathValue.length > 0 ? pathValue : null;
|
||||
}
|
||||
|
||||
export function readPathFromLoginShell(
|
||||
shell: string,
|
||||
execFile: ExecFileSyncLike = NodeChildProcess.execFileSync,
|
||||
|
||||
Reference in new issue
Block a user