From ac05ddc0f93f5638743dc690b28dbe0c1a391ec8 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 18 Feb 2026 08:41:07 +0000 Subject: [PATCH] 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. Applied via @cursor push command --- apps/web/src/projectScripts.ts | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/apps/web/src/projectScripts.ts b/apps/web/src/projectScripts.ts index c09a801237fc3c813fc636f2bf027f6ae1591e1b..4084df8456b9ce3e706e76f1a0ebb63491a516f7 100644 --- a/apps/web/src/projectScripts.ts +++ b/apps/web/src/projectScripts.ts @@ -1,10 +1,7 @@ import type { ProjectScript } from "@t3tools/contracts"; -import { isWindowsPlatform } from "./lib/utils"; - const SCRIPT_RUN_COMMAND_PATTERN = /^script\.([a-z0-9][a-z0-9-]*)\.run$/; const MAX_SCRIPT_ID_LENGTH = 64; -const ENV_KEY_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/; function normalizeScriptId(value: string): string { const cleaned = value @@ -52,37 +49,6 @@ export function nextProjectScriptId(name: string, existingIds: Iterable) return `${baseId}-${Date.now()}`.slice(0, MAX_SCRIPT_ID_LENGTH); } -function shellEscapePosix(value: string): string { - return `'${value.replace(/'/g, `'\\''`)}'`; -} - -function shellEscapeWindowsSetValue(value: string): string { - return value.replace(/\^/g, "^^").replace(/%/g, "^%").replace(/"/g, '""'); -} - -function injectEnvIntoShellCommand( - command: string, - env: Record, - platform = typeof navigator === "undefined" ? "" : navigator.platform, -): string { - const entries = Object.entries(env).filter( - ([key, value]) => ENV_KEY_PATTERN.test(key) && value.length > 0, - ); - if (entries.length === 0) { - return command; - } - - if (isWindowsPlatform(platform)) { - const prefixes = entries.map( - ([key, value]) => `set "${key}=${shellEscapeWindowsSetValue(value)}"`, - ); - return `${prefixes.join(" && ")} && ${command}`; - } - - const assignments = entries.map(([key, value]) => `${key}=${shellEscapePosix(value)}`).join(" "); - return `env ${assignments} ${command}`; -} - interface ProjectScriptRuntimeEnvInput { project: { cwd: string; -- 2.54.0