Fix powershell encoding.

This commit is contained in:
Christian Gunderman
2026-02-02 11:41:58 -08:00
parent e860f517c0
commit 5b984bffae
2 changed files with 35 additions and 7 deletions

View File

@@ -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');
});
});

View File

@@ -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',
};
}