Skip to content

Commit 962bac7

Browse files
authored
Update platform.ts
1 parent be41e5b commit 962bac7

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/platform.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,18 @@ export function getDefaultPowerShellPath(
6666
use32Bit: boolean = false): string | null {
6767

6868
let powerShellExePath;
69+
let psCoreInstallPath;
6970

7071
// Find the path to powershell.exe based on the current platform
7172
// and the user's desire to run the x86 version of PowerShell
7273
if (platformDetails.operatingSystem === OperatingSystem.Windows) {
73-
const psCoreInstallPath =
74-
(platformDetails.isProcess64Bit ? process.env.ProgramFiles : process.env.ProgramW6432) + "\\PowerShell";
74+
if (use32Bit) {
75+
psCoreInstallPath =
76+
(platformDetails.isProcess64Bit ? process.env.ProgramW6432 : process.env.ProgramFiles) + "\\PowerShell";
77+
} else {
78+
79+
psCoreInstallPath = psCoreInstallPath = process.env.ProgramFiles + "\\PowerShell";
80+
}
7581
if (fs.existsSync(psCoreInstallPath)) {
7682
const arch = platformDetails.isProcess64Bit ? "(x64)" : "(x86)";
7783
const psCorePaths =
@@ -87,22 +93,20 @@ export function getDefaultPowerShellPath(
8793
}));
8894

8995
if (psCorePaths) {
90-
powerShellExePath = psCorePaths[0].exePath;
96+
return powerShellExePath = psCorePaths[0].exePath;
9197
}
92-
93-
} else {
94-
if (use32Bit) {
98+
}
99+
if (use32Bit) {
95100
powerShellExePath =
96101
platformDetails.isOS64Bit && platformDetails.isProcess64Bit
97102
? SysWow64PowerShellPath
98103
: System32PowerShellPath;
99-
} else {
104+
} else {
100105
powerShellExePath =
101106
!platformDetails.isOS64Bit || platformDetails.isProcess64Bit
102107
? System32PowerShellPath
103108
: SysnativePowerShellPath;
104109
}
105-
}
106110
} else if (platformDetails.operatingSystem === OperatingSystem.MacOS) {
107111
// Always default to the stable version of PowerShell (if installed) but handle case of only Preview installed
108112
powerShellExePath = macOSExePath;

0 commit comments

Comments
 (0)