MCPcopy
hub / github.com/PowerShell/vscode-powershell / start

Method start

src/process.ts:42–180  ·  view source on GitHub ↗
(
        cancellationToken: vscode.CancellationToken,
    )

Source from the content-addressed store, hash-verified

40 }
41
42 public async start(
43 cancellationToken: vscode.CancellationToken,
44 ): Promise<IEditorServicesSessionDetails | undefined> {
45 const psesModulePath = path.resolve(
46 __dirname,
47 this.bundledModulesPath,
48 "PowerShellEditorServices/PowerShellEditorServices.psd1",
49 );
50
51 const featureFlags =
52 this.sessionSettings.developer.featureFlags.length > 0
53 ? this.sessionSettings.developer.featureFlags
54 .map((f) => `'${f}'`)
55 .join(", ")
56 : "";
57
58 this.startPsesArgs +=
59 `-LogPath '${utils.escapeSingleQuotes(this.logDirectoryPath.fsPath)}' ` +
60 `-SessionDetailsPath '${utils.escapeSingleQuotes(this.sessionFilePath.fsPath)}' ` +
61 `-FeatureFlags @(${featureFlags}) `;
62
63 if (this.sessionSettings.integratedConsole.useLegacyReadLine) {
64 this.startPsesArgs += "-UseLegacyReadLine";
65 }
66
67 const powerShellArgs: string[] = [];
68
69 const useLoginShell: boolean =
70 (utils.isMacOS && this.sessionSettings.startAsLoginShell.osx) ||
71 (utils.isLinux && this.sessionSettings.startAsLoginShell.linux);
72
73 if (useLoginShell && this.isLoginShell(this.exePath)) {
74 // This MUST be the first argument.
75 powerShellArgs.push("-Login");
76 }
77
78 powerShellArgs.push("-NoProfile");
79
80 // Only add ExecutionPolicy param on Windows
81 if (
82 utils.isWindows &&
83 this.sessionSettings.developer.setExecutionPolicy
84 ) {
85 powerShellArgs.push("-ExecutionPolicy", "Bypass");
86 }
87
88 const startEditorServices =
89 "Import-Module '" +
90 utils.escapeSingleQuotes(psesModulePath) +
91 "'; Start-EditorServices " +
92 this.startPsesArgs;
93
94 // On Windows we unfortunately can't Base64 encode the startup command
95 // because it annoys some poorly implemented anti-virus scanners.
96 if (utils.isWindows) {
97 powerShellArgs.push("-Command", startEditorServices);
98 } else {
99 // Otherwise use -EncodedCommand for better quote support.

Callers 1

Calls 9

isLoginShellMethod · 0.95
deleteSessionFileMethod · 0.95
onTerminalCloseMethod · 0.95
getPidMethod · 0.95
waitForSessionFileMethod · 0.95
validateCwdSettingFunction · 0.90
showMethod · 0.80
writeDebugMethod · 0.65
writeMethod · 0.65

Tested by

no test coverage detected