From 5b984bffae779511ddc189d7a5ce088fd5ecd022 Mon Sep 17 00:00:00 2001 From: Christian Gunderman Date: Mon, 2 Feb 2026 11:41:58 -0800 Subject: [PATCH] Fix powershell encoding. --- packages/core/src/utils/shell-utils.test.ts | 30 +++++++++++++++++---- packages/core/src/utils/shell-utils.ts | 12 +++++++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/packages/core/src/utils/shell-utils.test.ts b/packages/core/src/utils/shell-utils.test.ts index 81b43abf50..a4e7bf6f8f 100644 --- a/packages/core/src/utils/shell-utils.test.ts +++ b/packages/core/src/utils/shell-utils.test.ts @@ -429,7 +429,11 @@ describe('getShellConfiguration', () => { delete process.env['ComSpec']; const config = getShellConfiguration(); expect(config.executable).toBe('powershell.exe'); - expect(config.argsPrefix).toEqual(['-NoProfile', '-Command']); + expect(config.argsPrefix).toEqual([ + '-NoProfile', + '-Command', + '$OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;', + ]); expect(config.shell).toBe('powershell'); }); @@ -438,7 +442,11 @@ describe('getShellConfiguration', () => { process.env['ComSpec'] = cmdPath; const config = getShellConfiguration(); expect(config.executable).toBe('powershell.exe'); - expect(config.argsPrefix).toEqual(['-NoProfile', '-Command']); + expect(config.argsPrefix).toEqual([ + '-NoProfile', + '-Command', + '$OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;', + ]); expect(config.shell).toBe('powershell'); }); @@ -448,7 +456,11 @@ describe('getShellConfiguration', () => { process.env['ComSpec'] = psPath; const config = getShellConfiguration(); expect(config.executable).toBe(psPath); - expect(config.argsPrefix).toEqual(['-NoProfile', '-Command']); + expect(config.argsPrefix).toEqual([ + '-NoProfile', + '-Command', + '$OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;', + ]); expect(config.shell).toBe('powershell'); }); @@ -457,7 +469,11 @@ describe('getShellConfiguration', () => { process.env['ComSpec'] = pwshPath; const config = getShellConfiguration(); expect(config.executable).toBe(pwshPath); - expect(config.argsPrefix).toEqual(['-NoProfile', '-Command']); + expect(config.argsPrefix).toEqual([ + '-NoProfile', + '-Command', + '$OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;', + ]); expect(config.shell).toBe('powershell'); }); @@ -465,7 +481,11 @@ describe('getShellConfiguration', () => { process.env['ComSpec'] = 'C:\\Path\\To\\POWERSHELL.EXE'; const config = getShellConfiguration(); expect(config.executable).toBe('C:\\Path\\To\\POWERSHELL.EXE'); - expect(config.argsPrefix).toEqual(['-NoProfile', '-Command']); + expect(config.argsPrefix).toEqual([ + '-NoProfile', + '-Command', + '$OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;', + ]); expect(config.shell).toBe('powershell'); }); }); diff --git a/packages/core/src/utils/shell-utils.ts b/packages/core/src/utils/shell-utils.ts index 3a002f2895..edb65ba02f 100644 --- a/packages/core/src/utils/shell-utils.ts +++ b/packages/core/src/utils/shell-utils.ts @@ -552,7 +552,11 @@ export function getShellConfiguration(): ShellConfiguration { ) { return { executable: comSpec, - argsPrefix: ['-NoProfile', '-Command'], + argsPrefix: [ + '-NoProfile', + '-Command', + '$OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;', + ], shell: 'powershell', }; } @@ -561,7 +565,11 @@ export function getShellConfiguration(): ShellConfiguration { // Default to PowerShell for all other Windows configurations. return { executable: 'powershell.exe', - argsPrefix: ['-NoProfile', '-Command'], + argsPrefix: [ + '-NoProfile', + '-Command', + '$OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;', + ], shell: 'powershell', }; }