(data: Buffer)
| 8 | |
| 9 | // Automatically decode the buffer according to the platform to avoid garbled Chinese |
| 10 | function getDecodedOutput(data: Buffer): string { |
| 11 | if (process.platform === "win32") { |
| 12 | try { |
| 13 | let out = iconv.decode(data, "utf-8"); |
| 14 | if (/�/.test(out)) { |
| 15 | out = iconv.decode(data, "gbk"); |
| 16 | } |
| 17 | return out; |
| 18 | } catch { |
| 19 | return iconv.decode(data, "gbk"); |
| 20 | } |
| 21 | } else { |
| 22 | return data.toString(); |
| 23 | } |
| 24 | } // Simple helper function to use login shell on Unix/macOS and PowerShell on Windows |
| 25 | function getShellCommand(command: string): { shell: string; args: string[] } { |
| 26 | if (process.platform === "win32") { |
| 27 | // Windows: Use PowerShell |
no test coverage detected