-
Notifications
You must be signed in to change notification settings - Fork 498
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
Fix PowerShell MSIX (Store) detection #3202
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,7 +268,7 @@ export class PowerShellExeFinder { | |
// Find the base directory for MSIX application exe shortcuts | ||
const msixAppDir = path.join(process.env.LOCALAPPDATA, "Microsoft", "WindowsApps"); | ||
|
||
if (!fs.existsSync(msixAppDir)) { | ||
if (!fileExistsSync(msixAppDir)) { | ||
return null; | ||
} | ||
|
||
|
@@ -310,7 +310,13 @@ export class PowerShellExeFinder { | |
const powerShellInstallBaseDir = path.join(programFilesPath, "PowerShell"); | ||
|
||
// Ensure the base directory exists | ||
if (!(fs.existsSync(powerShellInstallBaseDir) && fs.lstatSync(powerShellInstallBaseDir).isDirectory())) { | ||
try { | ||
const powerShellInstallBaseDirLStat = fs.lstatSync(powerShellInstallBaseDir); | ||
if (!powerShellInstallBaseDirLStat.isDirectory()) | ||
{ | ||
return null; | ||
} | ||
} catch { | ||
return null; | ||
} | ||
|
||
|
@@ -469,6 +475,17 @@ export function getWindowsSystemPowerShellPath(systemFolderName: string) { | |
"powershell.exe"); | ||
} | ||
|
||
function fileExistsSync(filePath: string): boolean { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The node docs aren't wrong about this kinda being an anti-pattern.
We're essentially making our own |
||
try { | ||
// This will throw if the path does not exist, | ||
// and otherwise returns a value that we don't care about | ||
fs.lstatSync(filePath); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probably ought to just be |
||
return true; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
|
||
interface IPossiblePowerShellExe extends IPowerShellExeDetails { | ||
exists(): boolean; | ||
} | ||
|
@@ -491,7 +508,7 @@ class PossiblePowerShellExe implements IPossiblePowerShellExe { | |
|
||
public exists(): boolean { | ||
if (this.knownToExist === undefined) { | ||
this.knownToExist = fs.existsSync(this.exePath); | ||
this.knownToExist = fileExistsSync(this.exePath); | ||
} | ||
return this.knownToExist; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call to remove this anyway: