()
| 58 | } |
| 59 | |
| 60 | function detectViaParentProcessInspection(): ShellName | null { |
| 61 | try { |
| 62 | if (process.platform === 'win32') { |
| 63 | const parentProcess = execSync( |
| 64 | 'wmic process get ParentProcessId,CommandLine', |
| 65 | { stdio: 'pipe' }, |
| 66 | ) |
| 67 | .toString() |
| 68 | .toLowerCase() |
| 69 | |
| 70 | if (parentProcess.includes('powershell')) return 'powershell' |
| 71 | if (parentProcess.includes('cmd.exe')) return 'cmd.exe' |
| 72 | } else { |
| 73 | const parentProcess = execSync(`ps -p ${process.ppid} -o comm=`, { |
| 74 | stdio: 'pipe', |
| 75 | }) |
| 76 | .toString() |
| 77 | .trim() |
| 78 | const normalized = normalizeCandidate(parentProcess) |
| 79 | if (normalized) return normalized |
| 80 | } |
| 81 | } catch { |
| 82 | // Ignore inspection errors |
| 83 | } |
| 84 | |
| 85 | return null |
| 86 | } |
| 87 | |
| 88 | function normalizeCandidate(value?: string | null): ShellName | null { |
| 89 | if (!value) { |
no test coverage detected