fix(non-interactive-env): use detectShellType instead of hardcoded win32 check (#3310, #3338)

Hardcoded platform check forced PowerShell env syntax on Windows
regardless of the actual shell. Replaced with detectShellType() so
Git Bash, WSL, and similar environments use unix prefixes while
native PowerShell continues to get powershell prefixes.

🤖 Generated with OhMyOpenCode assistance
https://github.com/code-yeongyu/oh-my-opencode
This commit is contained in:
YeonGyu-Kim
2026-04-12 02:29:28 +09:00
parent 2d8b4a9d53
commit 796a646c63
2 changed files with 104 additions and 10 deletions
@@ -1,6 +1,7 @@
import type { PluginInput } from "@opencode-ai/plugin"
import { HOOK_NAME, NON_INTERACTIVE_ENV, SHELL_COMMAND_PATTERNS } from "./constants"
import { log, buildEnvPrefix } from "../../shared"
import { detectShellType } from "../../shared/shell-env"
export * from "./constants"
export * from "./detector"
@@ -52,7 +53,7 @@ export function createNonInteractiveEnvHook(_ctx: PluginInput) {
// The env vars (GIT_EDITOR=:, EDITOR=:, etc.) must ALWAYS be injected
// for git commands to prevent interactive prompts.
const shellType = process.platform === "win32" ? "powershell" : "unix"
const shellType = detectShellType()
const envPrefix = buildEnvPrefix(NON_INTERACTIVE_ENV, shellType)
// Check if the command already starts with the prefix to avoid stacking.