Merged
Show file tree
Hide file tree
Changes from all commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Failed to load files.
Original file line numberDiff line numberDiff line change
Expand Up@@ -239,17 +239,17 @@ export class PowerShellExeFinder {
}

exePath = untildify(exePath);

// Always search for what the user gave us first
yield new PossiblePowerShellExe(exePath, versionName);

// Also search for `pwsh[.exe]` and `powershell[.exe]` if missing
const args: [string, undefined, boolean, boolean]
// Must be a tuple type and is suppressing the warning
= [versionName, undefined, true, true];

// Handle Windows where '.exe' and 'powershell' are things
// Always search for what the user gave us first, but with the warning
// suppressed so we can display it after all possibilities are exhausted
yield new PossiblePowerShellExe(exePath, ...args);

// Also search for `pwsh[.exe]` and `powershell[.exe]` if missing
if (this.platformDetails.operatingSystem === OperatingSystem.Windows) {
// Handle Windows where '.exe' and 'powershell' are things
if (!exePath.endsWith("pwsh.exe") && !exePath.endsWith("powershell.exe")) {
if (exePath.endsWith("pwsh") || exePath.endsWith("powershell")) {
// Add extension if that was missing
Expand All@@ -260,9 +260,13 @@ export class PowerShellExeFinder {
yield new PossiblePowerShellExe(path.join(exePath, "pwsh.exe"), ...args);
yield new PossiblePowerShellExe(path.join(exePath, "powershell.exe"), ...args);
}
} else if (!exePath.endsWith("pwsh")) { // Always just 'pwsh' on non-Windows
} else if (!exePath.endsWith("pwsh")) {
// Always just 'pwsh' on non-Windows
yield new PossiblePowerShellExe(path.join(exePath, "pwsh"), ...args);
}

// If we're still being iterated over, no permutation of the given path existed so yield an object with the warning unsuppressed
yield new PossiblePowerShellExe(exePath, versionName, false, undefined, false);
}
}
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -468,7 +468,17 @@ if (process.platform === "win32") {
isProcess64Bit: true,
},
environmentVars: {},
// Note that for each given path, we expect:
// 1. The path as-is.
// 2. Any expected permutations of the path (for example, with a tilde or folder expanded, and/or '.exe' added).
// 3. The path as-is again (in order for a warning to be displayed at the correct time).
// An improvement here would be to check the suppressWarning field, but it's not currently exposed.
expectedPowerShellSequence: [
{
exePath: "C:\\Users\\test\\pwsh\\pwsh.exe",
displayName: "pwsh",
supportsProperArguments: true
},
{
exePath: "C:\\Users\\test\\pwsh\\pwsh.exe",
displayName: "pwsh",
Expand All@@ -479,6 +489,11 @@ if (process.platform === "win32") {
displayName: "pwsh-tilde",
supportsProperArguments: true
},
{
exePath: path.join(os.homedir(), "pwsh", "pwsh.exe"),
displayName: "pwsh-tilde",
supportsProperArguments: true
},
{
exePath: "C:\\Users\\test\\pwsh\\pwsh",
displayName: "pwsh-no-exe",
Expand All@@ -499,6 +514,11 @@ if (process.platform === "win32") {
displayName: "pwsh-no-exe",
supportsProperArguments: true
},
{
exePath: "C:\\Users\\test\\pwsh\\pwsh",
displayName: "pwsh-no-exe",
supportsProperArguments: true
},
{
exePath: "C:\\Users\\test\\pwsh\\",
displayName: "pwsh-folder",
Expand All@@ -514,6 +534,11 @@ if (process.platform === "win32") {
displayName: "pwsh-folder",
supportsProperArguments: true
},
{
exePath: "C:\\Users\\test\\pwsh\\",
displayName: "pwsh-folder",
supportsProperArguments: true
},
{
exePath: "C:\\Users\\test\\pwsh",
displayName: "pwsh-folder-no-slash",
Expand All@@ -534,6 +559,16 @@ if (process.platform === "win32") {
displayName: "pwsh-folder-no-slash",
supportsProperArguments: true
},
{
exePath: "C:\\Users\\test\\pwsh",
displayName: "pwsh-folder-no-slash",
supportsProperArguments: true
},
{
exePath: "C:\\Users\\test\\pwsh\\pwsh.exe",
displayName: "pwsh-single-quotes",
supportsProperArguments: true
},
{
exePath: "C:\\Users\\test\\pwsh\\pwsh.exe",
displayName: "pwsh-single-quotes",
Expand All@@ -544,6 +579,11 @@ if (process.platform === "win32") {
displayName: "pwsh-double-quotes",
supportsProperArguments: true
},
{
exePath: "C:\\Users\\test\\pwsh\\pwsh.exe",
displayName: "pwsh-double-quotes",
supportsProperArguments: true
},
],
filesystem: {},
}
Expand DownExpand Up@@ -760,19 +800,34 @@ if (process.platform === "win32") {

successAdditionalTestCases = [
{ // Also sufficient for macOS as the behavior is the same
name: "Linux (Additional PowerShell Executables)",
name: "Linux/macOS (Additional PowerShell Executables)",
platformDetails: {
operatingSystem: platform.OperatingSystem.Linux,
isOS64Bit: true,
isProcess64Bit: true,
},
environmentVars: {},
// Note that for each given path, we expect:
// 1. The path as-is.
// 2. Any expected permutations of the path (for example, with a tilde or folder expanded).
// 3. The path as-is again (in order for a warning to be displayed at the correct time).
// An improvement here would be to check the suppressWarning field, but it's not currently exposed.
expectedPowerShellSequence: [
{
exePath: "/home/bin/pwsh",
displayName: "pwsh",
supportsProperArguments: true
},
{
exePath: "/home/bin/pwsh",
displayName: "pwsh",
supportsProperArguments: true
},
{
exePath: path.join(os.homedir(), "bin", "pwsh"),
displayName: "pwsh-tilde",
supportsProperArguments: true
},
{
exePath: path.join(os.homedir(), "bin", "pwsh"),
displayName: "pwsh-tilde",
Expand All@@ -788,6 +843,11 @@ if (process.platform === "win32") {
displayName: "pwsh-folder",
supportsProperArguments: true
},
{
exePath: "/home/bin/",
displayName: "pwsh-folder",
supportsProperArguments: true
},
{
exePath: "/home/bin",
displayName: "pwsh-folder-no-slash",
Expand All@@ -798,6 +858,16 @@ if (process.platform === "win32") {
displayName: "pwsh-folder-no-slash",
supportsProperArguments: true
},
{
exePath: "/home/bin",
displayName: "pwsh-folder-no-slash",
supportsProperArguments: true
},
{
exePath: "/home/bin/pwsh",
displayName: "pwsh-single-quotes",
supportsProperArguments: true
},
{
exePath: "/home/bin/pwsh",
displayName: "pwsh-single-quotes",
Expand All@@ -808,6 +878,11 @@ if (process.platform === "win32") {
displayName: "pwsh-double-quotes",
supportsProperArguments: true
},
{
exePath: "/home/bin/pwsh",
displayName: "pwsh-double-quotes",
supportsProperArguments: true
},
],
filesystem: {},
}
Expand Down