Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to handle PS Core binary name change #1071

Merged
merged 2 commits into from
Oct 26, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ export function getDefaultPowerShellPath(
}
else if (platformDetails.operatingSystem == OperatingSystem.MacOS) {
powerShellExePath = "/usr/local/bin/powershell";
if (fs.existsSync("/usr/loca/bin/pwsh")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed an 'l' in 'local' in the path

powerShellExePath = "/usr/local/bin/pwsh";
}
}
else if (platformDetails.operatingSystem == OperatingSystem.Linux) {
powerShellExePath = "/usr/bin/powershell";
if (fs.existsSync("/usr/bin/pwsh")) {
powerShellExePath = "/usr/bin/pwsh";
}
}

return powerShellExePath;
Expand Down Expand Up @@ -146,9 +152,14 @@ export function getAvailablePowerShellExes(platformDetails: PlatformDetails): Po
.map(item => path.join(psCoreInstallPath, item))
.filter(item => fs.lstatSync(item).isDirectory())
.map(item => {
let exePath = path.join(item, "pwsh.exe");
if (!fs.existsSync(exePath)) {
exePath = path.join(item, "powershell.exe");
}

return {
versionName: `PowerShell Core ${path.parse(item).base}`,
exePath: path.join(item, "powershell.exe")
exePath: exePath
};
});

Expand All @@ -158,12 +169,10 @@ export function getAvailablePowerShellExes(platformDetails: PlatformDetails): Po
}
}
else {

paths.push({
versionName: "PowerShell Core",
exePath:
os.platform() === "darwin"
? "/usr/local/bin/powershell"
: "/usr/bin/powershell"
exePath: this.getDefaultPowerShellPath(platformDetails)
});
}

Expand Down
8 changes: 8 additions & 0 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,14 @@ export class SessionManager implements Middleware {
this.sessionSettings.developer.powerShellExePath ||
"").trim();

// New versions of PS Core uninstall the previous version
// so make sure the path stored in the settings exists.
if (!fs.existsSync(powerShellExePath)) {
this.log.write(
`Path specified by 'powerShellExePath' setting - '${powerShellExePath}' - not found, reverting to default PowerShell path.`);
powerShellExePath = "";
}

if (this.platformDetails.operatingSystem === OperatingSystem.Windows &&
powerShellExePath.length > 0) {

Expand Down