authorgravatar for cursoragent@cursor.comCursor Agent <cursoragent@cursor.com> 2026-02-18 08:41:07+00:00
committergravatar for jmarminge@gmail.comJulius Marminge <jmarminge@gmail.com> 2026-02-18 00:59:06-08:00
logac05ddc0f93f5638743dc690b28dbe0c1a391ec8
tree2aea1e4bf361bf78bdce7a55b7b9f9e8111fa211
parent0e73dc15275f24b7ba94a7c200939907690f70b2

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

1 files changed, 0 insertions(+), 34 deletions(-)

apps/web/src/projectScripts.ts-34
...@@ -1,10 +1,7 @@...@@ -1,10 +1,7 @@
1import type { ProjectScript } from "@t3tools/contracts";1import type { ProjectScript } from "@t3tools/contracts";
22
3import { isWindowsPlatform } from "./lib/utils";
4
5const SCRIPT_RUN_COMMAND_PATTERN = /^script\.([a-z0-9][a-z0-9-]*)\.run$/;3const SCRIPT_RUN_COMMAND_PATTERN = /^script\.([a-z0-9][a-z0-9-]*)\.run$/;
6const MAX_SCRIPT_ID_LENGTH = 64;4const MAX_SCRIPT_ID_LENGTH = 64;
7const ENV_KEY_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
85
9function normalizeScriptId(value: string): string {6function normalizeScriptId(value: string): string {
10 const cleaned = value7 const cleaned = value
...@@ -52,37 +49,6 @@ export function nextProjectScriptId(name: string, existingIds: Iterable<string>)...@@ -52,37 +49,6 @@ export function nextProjectScriptId(name: string, existingIds: Iterable<string>)
52 return `${baseId}-${Date.now()}`.slice(0, MAX_SCRIPT_ID_LENGTH);49 return `${baseId}-${Date.now()}`.slice(0, MAX_SCRIPT_ID_LENGTH);
53}50}
5451
55function shellEscapePosix(value: string): string {
56 return `'${value.replace(/'/g, `'\\''`)}'`;
57}
58
59function shellEscapeWindowsSetValue(value: string): string {
60 return value.replace(/\^/g, "^^").replace(/%/g, "^%").replace(/"/g, '""');
61}
62
63function 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
86interface ProjectScriptRuntimeEnvInput {52interface ProjectScriptRuntimeEnvInput {
87 project: {53 project: {
88 cwd: string;54 cwd: string;