History

Remove dead code: unused shell env injection functions

Remove injectEnvIntoShellCommand, shellEscapePosix, shellEscapeWindowsSetValue, ENV_KEY_PATTERN, and the now-unused isWindowsPlatform import. These were leftover from an earlier approach where env vars were injected into the shell command string, replaced by passing env directly to terminal.open.

Cursor Agent committed 8 months ago

Commit d169cfd1 parent e31fcbd1 file · +0 −34Browse files

Unified · Split

apps/web/src/projectScripts.ts+0−34
@@ -1,10 +1,7 @@
11 import type { ProjectScript } from "@t3tools/contracts";
22
3−import { isWindowsPlatform } from "./lib/utils";
4−
53 const SCRIPT_RUN_COMMAND_PATTERN = /^script\.([a-z0-9][a-z0-9-]*)\.run$/;
64 const MAX_SCRIPT_ID_LENGTH = 64;
7−const ENV_KEY_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
85
96 function normalizeScriptId(value: string): string {
107 const cleaned = value
@@ -52,37 +49,6 @@ export function nextProjectScriptId(name: string, existingIds: Iterable<string>) · 41 unmodified lines
5249 return `${baseId}-${Date.now()}`.slice(0, MAX_SCRIPT_ID_LENGTH);
5350 }
5451
55−function shellEscapePosix(value: string): string {
56− return `'${value.replace(/'/g, `'\\''`)}'`;
57−}
58−
59−function shellEscapeWindowsSetValue(value: string): string {
60− return value.replace(/\^/g, "^^").replace(/%/g, "^%").replace(/"/g, '""');
61−}
62−
63−function injectEnvIntoShellCommand(
64− command: string,
65− env: Record<string, string>,
66− platform = typeof navigator === "undefined" ? "" : navigator.platform,
67−): string {
68− const entries = Object.entries(env).filter(
69− ([key, value]) => ENV_KEY_PATTERN.test(key) && value.length > 0,
70− );
71− if (entries.length === 0) {
72− return command;
73− }
74−
75− if (isWindowsPlatform(platform)) {
76− const prefixes = entries.map(
77− ([key, value]) => `set "${key}=${shellEscapeWindowsSetValue(value)}"`,
78− );
79− return `${prefixes.join(" && ")} && ${command}`;
80− }
81−
82− const assignments = entries.map(([key, value]) => `${key}=${shellEscapePosix(value)}`).join(" ");
83− return `env ${assignments} ${command}`;
84−}
85−
8652 interface ProjectScriptRuntimeEnvInput {
8753 project: {
8854 cwd: string;