Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8fbbfce

Browse files
Automatically find "PowerShell Daily" at its common path (#4331)
1 parent 3d72823 commit 8fbbfce

File tree

3 files changed

+71
-7
lines changed

3 files changed

+71
-7
lines changed

‎src/features/ShowHelp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ShowHelpFeature extends LanguageClientConsumer {
1818
constructor() {
1919
super();
2020
this.command = vscode.commands.registerCommand("PowerShell.ShowHelp", async (item?) => {
21-
if (!item||!item.Name) {
21+
if (!item?.Name) {
2222

2323
const editor = vscode.window.activeTextEditor;
2424
if (editor === undefined) {

‎src/platform.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ export class PowerShellExeFinder {
211211

212212
break;
213213
}
214+
215+
// Look for PSCore daily
216+
yield this.findPSCoreDaily();
214217
}
215218

216219
/**
@@ -260,6 +263,42 @@ export class PowerShellExeFinder {
260263
}
261264
}
262265

266+
/**
267+
* If the daily was installed via 'https://aka.ms/install-powershell.ps1', then
268+
* this is the default installation location:
269+
*
270+
* if ($IsWinEnv) {
271+
* $Destination = "$env:LOCALAPPDATA\Microsoft\powershell"
272+
* } else {
273+
* $Destination = "~/.powershell"
274+
* }
275+
*
276+
* if ($Daily) {
277+
* $Destination = "${Destination}-daily"
278+
* }
279+
*/
280+
private findPSCoreDaily(): IPossiblePowerShellExe | undefined {
281+
switch (this.platformDetails.operatingSystem) {
282+
case OperatingSystem.Linux:
283+
case OperatingSystem.MacOS: {
284+
const exePath = path.join(os.homedir(), ".powershell-daily", "pwsh");
285+
return new PossiblePowerShellExe(exePath, "PowerShell Daily");
286+
}
287+
288+
case OperatingSystem.Windows: {
289+
// We can't proceed if there's no LOCALAPPDATA path
290+
if (!process.env.LOCALAPPDATA) {
291+
return undefined;
292+
}
293+
const exePath = path.join(process.env.LOCALAPPDATA, "Microsoft", "powershell-daily", "pwsh.exe");
294+
return new PossiblePowerShellExe(exePath, "PowerShell Daily");
295+
}
296+
297+
case OperatingSystem.Unknown:
298+
return undefined;
299+
}
300+
}
301+
263302
private findPSCoreDotnetGlobalTool(): IPossiblePowerShellExe {
264303
const exeName: string = this.platformDetails.operatingSystem === OperatingSystem.Windows
265304
? "pwsh.exe"

‎test/core/platform.test.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import * as assert from "assert";
55
import mockFS = require("mock-fs");
66
import FileSystem = require("mock-fs/lib/filesystem");
7+
import * as os from "os";
78
import * as path from "path";
89
import rewire = require("rewire");
910
import * as sinon from "sinon";
@@ -61,14 +62,13 @@ interface ITestPlatformSuccessCase extends ITestPlatform {
6162
// Platform configurations where we expect to find a set of PowerShells
6263
let successTestCases: ITestPlatformSuccessCase[];
6364

64-
let msixAppDir: string;
65-
let pwshMsixPath: string;
66-
let pwshPreviewMsixPath: string;
6765

6866
if (process.platform === "win32") {
69-
msixAppDir = path.join(process.env.LOCALAPPDATA!, "Microsoft", "WindowsApps");
70-
pwshMsixPath = path.join(msixAppDir, "Microsoft.PowerShell_8wekyb3d8bbwe", "pwsh.exe");
71-
pwshPreviewMsixPath = path.join(msixAppDir, "Microsoft.PowerShellPreview_8wekyb3d8bbwe", "pwsh.exe");
67+
const msixAppDir = path.join(process.env.LOCALAPPDATA!, "Microsoft", "WindowsApps");
68+
const pwshMsixPath = path.join(msixAppDir, "Microsoft.PowerShell_8wekyb3d8bbwe", "pwsh.exe");
69+
const pwshPreviewMsixPath = path.join(msixAppDir, "Microsoft.PowerShellPreview_8wekyb3d8bbwe", "pwsh.exe");
70+
const pwshDailyDir = path.join(process.env.LOCALAPPDATA!, "Microsoft", "powershell-daily");
71+
const pwshDailyPath = path.join(pwshDailyDir, "pwsh.exe");
7272

7373
successTestCases = [
7474
{
@@ -124,6 +124,11 @@ if (process.platform === "win32") {
124124
displayName: "Windows PowerShell (x86)",
125125
supportsProperArguments: true
126126
},
127+
{
128+
exePath: pwshDailyPath,
129+
displayName: "PowerShell Daily",
130+
supportsProperArguments: true
131+
}
127132
],
128133
filesystem: {
129134
"C:\\Program Files\\PowerShell": {
@@ -156,6 +161,9 @@ if (process.platform === "win32") {
156161
"C:\\WINDOWS\\SysWOW64\\WindowsPowerShell\\v1.0": {
157162
"powershell.exe": "",
158163
},
164+
[pwshDailyDir]: {
165+
"pwsh.exe": "",
166+
}
159167
},
160168
},
161169
{
@@ -436,6 +444,7 @@ if (process.platform === "win32") {
436444
},
437445
];
438446
} else {
447+
const pwshDailyDir = path.join(os.homedir(), ".powershell-daily");
439448
successTestCases = [
440449
{
441450
name: "Linux (all installations)",
@@ -466,6 +475,11 @@ if (process.platform === "win32") {
466475
displayName: "PowerShell Preview Snap",
467476
supportsProperArguments: true
468477
},
478+
{
479+
exePath: path.join(pwshDailyDir, "pwsh"),
480+
displayName: "PowerShell Daily",
481+
supportsProperArguments: true
482+
}
469483
],
470484
filesystem: {
471485
"/usr/bin": {
@@ -476,6 +490,9 @@ if (process.platform === "win32") {
476490
"pwsh": "",
477491
"pwsh-preview": "",
478492
},
493+
[pwshDailyDir]: {
494+
"pwsh": ""
495+
}
479496
},
480497
},
481498
{
@@ -497,12 +514,20 @@ if (process.platform === "win32") {
497514
displayName: "PowerShell Preview",
498515
supportsProperArguments: true
499516
},
517+
{
518+
exePath: path.join(pwshDailyDir, "pwsh"),
519+
displayName: "PowerShell Daily",
520+
supportsProperArguments: true
521+
}
500522
],
501523
filesystem: {
502524
"/usr/local/bin": {
503525
"pwsh": "",
504526
"pwsh-preview": "",
505527
},
528+
[pwshDailyDir]: {
529+
"pwsh": ""
530+
}
506531
},
507532
},
508533
{

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /