powershell.ts ×16

Frontier kind: Code frontier

unlabeled · c_256d829cb9bd

1071 tests · 7969 LOC · 40 files · introduces 0 tests · 103 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges103 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1110 ranges7969 lines · 40 files · Browse complete extent
All tests (intent)
1071 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 103 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/node/powershell.ts 103 introduced LOC · 16 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- powershell.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import * as os from 'os';
7 > import * as path from '../common/path.js';
8 > import * as pfs from './pfs.js';
9 >
10 > // This is required, since parseInt("7-preview") will return 7.
11 > const IntRegex: RegExp = /^\d+$/;
12 >
13 > const PwshMsixRegex: RegExp = /^Microsoft.PowerShell_.*/;
14 > const PwshPreviewMsixRegex: RegExp = /^Microsoft.PowerShellPreview_.*/;
15 >
16 > const enum Arch {
17 > x64,
18 > x86,
19 > ARM
20 > }
21 >
22 > let processArch: Arch;
23 > switch (process.arch) {
24 > case 'ia32':
25 processArch = Arch.x86;
26 break;
27 > case 'arm': powershell.ts
28 > case 'arm64':
29 processArch = Arch.ARM;
30 break;
31 > default: powershell.ts
32 > processArch = Arch.x64;
33 > break;
34 > }
35 >
36 > /*
37 > Currently, here are the values for these environment variables on their respective archs:
38 >
39 > On x86 process on x86:
40 > PROCESSOR_ARCHITECTURE is X86
41 > PROCESSOR_ARCHITEW6432 is undefined
42 >
43 > On x86 process on x64:
44 > PROCESSOR_ARCHITECTURE is X86
45 > PROCESSOR_ARCHITEW6432 is AMD64
46 >
47 > On x64 process on x64:
48 > PROCESSOR_ARCHITECTURE is AMD64
49 > PROCESSOR_ARCHITEW6432 is undefined
50 >
51 > On ARM process on ARM:
52 > PROCESSOR_ARCHITECTURE is ARM64
53 > PROCESSOR_ARCHITEW6432 is undefined
54 >
55 > On x86 process on ARM:
56 > PROCESSOR_ARCHITECTURE is X86
57 > PROCESSOR_ARCHITEW6432 is ARM64
58 >
59 > On x64 process on ARM:
60 > PROCESSOR_ARCHITECTURE is ARM64
61 > PROCESSOR_ARCHITEW6432 is undefined
62 > */
63 > let osArch: Arch;
64 > if (process.env['PROCESSOR_ARCHITEW6432']) {
65 osArch = process.env['PROCESSOR_ARCHITEW6432'] === 'ARM64'
66 ? Arch.ARM
67 : Arch.x64;
68 > } else if (process.env['PROCESSOR_ARCHITECTURE'] === 'ARM64') { powershell.ts
69 osArch = Arch.ARM;
70 > } else if (process.env['PROCESSOR_ARCHITECTURE'] === 'X86') { powershell.ts
71 osArch = Arch.x86;
72 > } else { powershell.ts
73 > osArch = Arch.x64;
74 > }
75 >
76 > export interface IPowerShellExeDetails {
77 > readonly displayName: string;
78 > readonly exePath: string;
79 > }
80 >
81 > interface IPossiblePowerShellExe extends IPowerShellExeDetails {
82 > exists(): Promise<boolean>;
83 > }
84 >
85 > class PossiblePowerShellExe implements IPossiblePowerShellExe {
86 > constructor(
87 public readonly exePath: string,
88 public readonly displayName: string,
89 private knownToExist?: boolean) { }
91 > public async exists(): Promise<boolean> {
92 if (this.knownToExist === undefined) {
93 this.knownToExist = await pfs.SymlinkSupport.existsFile(this.exePath);
95 return this.knownToExist;
96 }
97 > } powershell.ts
98 >
99 function getProgramFilesPath(
100 { useAlternateBitness = false }: { useAlternateBitness?: boolean } = {}): string | null {
118 return null;
119 }
121 async function findPSCoreWindowsInstallation(
122 { useAlternateBitness = false, findPreview = false }:
190 return new PossiblePowerShellExe(pwshExePath, `PowerShell${preview}${bitness}`, true);
191 }
193 async function findPSCoreMsix({ findPreview }: { findPreview?: boolean } = {}): Promise<IPossiblePowerShellExe | null> {
194 // We can't proceed if there's no LOCALAPPDATA path
220 return null;
221 }
223 function findPSCoreDotnetGlobalTool(): IPossiblePowerShellExe {
224 const dotnetGlobalToolExePath: string = path.join(os.homedir(), '.dotnet', 'tools', 'pwsh.exe');
226 return new PossiblePowerShellExe(dotnetGlobalToolExePath, '.NET Core PowerShell Global Tool');
227 }
229 function findPSCoreScoopInstallation(): IPossiblePowerShellExe {
230 const scoopAppsDir = path.join(os.homedir(), 'scoop', 'apps');
233 return new PossiblePowerShellExe(scoopPwsh, 'PowerShell (Scoop)');
234 }
236 function findWinPS(): IPossiblePowerShellExe | null {
237 const winPSPath = path.join(
242 return new PossiblePowerShellExe(winPSPath, 'Windows PowerShell', true);
243 }
245 > /**
246 > * Iterates through all the possible well-known PowerShell installations on a machine.
247 > * Returned values may not exist, but come with an .exists property
248 > * which will check whether the executable exists.
249 > */
250 async function* enumerateDefaultPowerShellInstallations(): AsyncIterable<IPossiblePowerShellExe> {
251 // Find PSCore stable first
304 }
305 }
307 > /**
308 > * Iterates through PowerShell installations on the machine according
309 > * to configuration passed in through the constructor.
310 > * PowerShell items returned by this object are verified
311 > * to exist on the filesystem.
312 > */
313 export async function* enumeratePowerShellInstallations(): AsyncIterable<IPowerShellExeDetails> {
314 // Get the default PowerShell installations first
319 }
320 }
322 > /**
323 > * Returns the first available PowerShell executable found in the search order.
324 > */
325 export async function getFirstAvailablePowerShellInstallation(): Promise<IPowerShellExeDetails | null> {
326 for await (const pwsh of enumeratePowerShellInstallations()) {